Personal tools

Monad/ST

From HaskellWiki

< Monad(Difference between revisions)
Jump to: navigation, search
m (Control.Monad.ST moved to Monad/ST)
(Adding standard class template)
Line 1: Line 1:
  +
{{Standard class|ST|module=Control.Monad.ST|module-doc=Control-Monad-ST|package=base}}
  +
  +
The ST monad provides support for ''strict'' state threads.
  +
  +
  +
==A discussion on the Haskell irc ==
 
From #haskell (see 13:05:37 in the [http://tunes.org/~nef/logs/haskell/07.02.07 log] ):
 
From #haskell (see 13:05:37 in the [http://tunes.org/~nef/logs/haskell/07.02.07 log] ):
   
Line 10: Line 16:
   
 
* DapperDan2: it strikes me that ST is like a lexical scope, where all the variables/state disappear when the function returns.
 
* DapperDan2: it strikes me that ST is like a lexical scope, where all the variables/state disappear when the function returns.
  +
[[Category:Standard classes]] [[Category:Monad]]

Revision as of 22:10, 7 February 2007

ST class (base)
import Control.Monad.ST

The ST monad provides support for strict state threads.


A discussion on the Haskell irc

From #haskell (see 13:05:37 in the log ):

  • TuringTest: ST lets you implement algorithms that are much more efficient with mutable memory used internally. But the whole "thread" of computation cannot exchange mutable state with the outside world, it can only exchange immutable state.
  • TuringTest: chessguy: You pass in normal Haskell values and then use ST to allocate mutable memory, then you initialize and play with it, then you put it away and return a normal Haskell value.
  • sjanssen: a monad that has mutable references and arrays, but has a "run" function that is referentially transparent
  • DapperDan2: it strikes me that ST is like a lexical scope, where all the variables/state disappear when the function returns.