base-4.13.0.0: Basic libraries
Copyright(c) The University of Glasgow 1994-2002
Licensesee libraries/base/LICENSE
Maintainercvs-ghc@haskell.org
Stabilityinternal
Portabilitynon-portable (GHC Extensions)
Safe HaskellUnsafe
LanguageHaskell2010

GHC.STRef

Description

References in the ST monad.

Synopsis

Documentation

data STRef s a #

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) #

Build a new STRef in the current state thread

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

Read the value of an STRef

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

Write a new value into an STRef