base-4.14.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 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) Source #

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