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"
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulebase-4.20.2.0Haskell2010
References in the ST monad.
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"
Build a new STRef in the current state thread
Read the value of an STRef
Write a new value into an STRef