GHC.STRef

Copyright (c) The University of Glasgow 1994-2002
License see libraries/base/LICENSE
Maintainer [email protected]
Stability internal
Portability non-portable (GHC Extensions)
Safe Haskell Unsafe
Language Haskell2010

Description

References in the ST monad.

data STRef s a Source

a value of type STRef s a is a mutable variable in state thread s, containing a value of type a

>>> :{
runST (do
    ref <- newSTRef "hello"
    x <- readSTRef ref
    writeSTRef ref (x ++ "world")
    readSTRef ref )
:}
"helloworld"

Constructors

STRef (MutVar# s a)
Instances
Instances details
Eq (STRef s a)

Pointer equality.

Since: base-2.1

Instance details

Defined in GHC.STRef

Methods

(==) :: STRef s a -> STRef s a -> Bool Source

(/=) :: STRef s a -> STRef s a -> Bool Source

newSTRef :: a -> ST s (STRef s a) Source

Build a new STRef in the current state thread

readSTRef :: STRef s a -> ST s a Source

Read the value of an STRef

writeSTRef :: STRef s a -> a -> ST s () Source

Write a new value into an STRef

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.10.2/docs/html/libraries/base-4.14.1.0/GHC-STRef.html