Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 1f2b142b9d2ef4849a6f5316fa1c5b12 > files > 1354

ghc-6.10.4-1mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Control.Monad.ST</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_Control-Monad-ST.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>base-4.1.0.0: Basic libraries</TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Control.Monad.ST</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>non-portable (requires universal quantification for runST)</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>experimental</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>libraries@haskell.org</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><B
>Contents</B
></TD
></TR
><TR
><TD
><DL
><DT
><A HREF="#1"
>The <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> Monad
</A
></DT
><DT
><A HREF="#2"
>Converting <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> to <TT
><A HREF="System-IO.html#t%3AIO"
>IO</A
></TT
>
</A
></DT
><DT
><A HREF="#3"
>Unsafe operations
</A
></DT
></DL
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
>This library provides support for <EM
>strict</EM
> state threads, as
 described in the PLDI '94 paper by John Launchbury and Simon Peyton
 Jones <EM
>Lazy Functional State Threads</EM
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A HREF="#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ArunST"
>runST</A
> ::  (<SPAN CLASS="keyword"
>forall</SPAN
> s.  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a) -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfixST"
>fixST</A
> ::  (a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a) -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AstToIO"
>stToIO</A
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> <A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
> a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AunsafeInterleaveST"
>unsafeInterleaveST</A
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AunsafeIOToST"
>unsafeIOToST</A
> ::  <A HREF="System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AunsafeSTToIO"
>unsafeSTToIO</A
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> a</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="1"
><A NAME="1"
>The <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> Monad
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A NAME="t:ST"
><A NAME="t%3AST"
></A
></A
><B
>ST</B
> s a </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
><P
>The strict state-transformer monad.
 A computation of type <TT
><TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> s a</TT
> transforms an internal state indexed
 by <TT
>s</TT
>, and returns a value of type <TT
>a</TT
>.
 The <TT
>s</TT
> parameter is either
</P
><UL
><LI
> an uninstantiated type variable (inside invocations of <TT
><A HREF="Control-Monad-ST.html#v%3ArunST"
>runST</A
></TT
>), or
</LI
><LI
> <TT
><A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
></TT
> (inside invocations of Control.Monad.ST.stToIO).
</LI
></UL
><P
>It serves to keep the internal states of different invocations
 of <TT
><A HREF="Control-Monad-ST.html#v%3ArunST"
>runST</A
></TT
> separate from each other and from invocations of
 Control.Monad.ST.stToIO.
</P
><P
>The <TT
><A HREF="Control-Monad.html#v%3A%3E%3E%3D"
>&gt;&gt;=</A
></TT
> and <TT
><A HREF="Control-Monad.html#v%3A%3E%3E"
>&gt;&gt;</A
></TT
> operations are strict in the state (though not in
 values stored in the state).  For example,
</P
><PRE
><TT
><A HREF="Control-Monad-ST.html#v%3ArunST"
>runST</A
></TT
> (writeSTRef _|_ v &gt;&gt;= f) = _|_</PRE
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:ST')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:ST" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Data-Typeable.html#t%3ATypeable2"
>Typeable2</A
> <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad.html#t%3AMonad"
>Monad</A
> (<A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad.html#t%3AFunctor"
>Functor</A
> (<A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Control-Monad-Fix.html#t%3AMonadFix"
>MonadFix</A
> (<A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s)</TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Text-Show.html#t%3AShow"
>Show</A
> (<A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a)</TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:runST"
><A NAME="v%3ArunST"
></A
></A
><B
>runST</B
> ::  (<SPAN CLASS="keyword"
>forall</SPAN
> s.  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a) -&gt; a</TD
></TR
><TR
><TD CLASS="doc"
>Return the value computed by a state transformer computation.
 The <TT
>forall</TT
> ensures that the internal state used by the <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
>
 computation is inaccessible to the rest of the program.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:fixST"
><A NAME="v%3AfixST"
></A
></A
><B
>fixST</B
> ::  (a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a) -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="doc"
>Allow the result of a state transformer computation to be used (lazily)
 inside the computation.
 Note that if <TT
>f</TT
> is strict, <TT
><TT
><A HREF="Control-Monad-ST.html#v%3AfixST"
>fixST</A
></TT
> f = _|_</TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="2"
><A NAME="2"
>Converting <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> to <TT
><A HREF="System-IO.html#t%3AIO"
>IO</A
></TT
>
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:stToIO"
><A NAME="v%3AstToIO"
></A
></A
><B
>stToIO</B
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> <A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
> a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> a</TD
></TR
><TR
><TD CLASS="doc"
>A monad transformer embedding strict state transformers in the <TT
><A HREF="System-IO.html#t%3AIO"
>IO</A
></TT
>
 monad.  The <TT
><A HREF="../ghc-prim/GHC-Prim.html#t%3ARealWorld"
>RealWorld</A
></TT
> parameter indicates that the internal state
 used by the <TT
><A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
></TT
> computation is a special one supplied by the <TT
><A HREF="System-IO.html#t%3AIO"
>IO</A
></TT
>
 monad, and thus distinct from those used by invocations of <TT
><A HREF="Control-Monad-ST.html#v%3ArunST"
>runST</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="3"
><A NAME="3"
>Unsafe operations
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:unsafeInterleaveST"
><A NAME="v%3AunsafeInterleaveST"
></A
></A
><B
>unsafeInterleaveST</B
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:unsafeIOToST"
><A NAME="v%3AunsafeIOToST"
></A
></A
><B
>unsafeIOToST</B
> ::  <A HREF="System-IO.html#t%3AIO"
>IO</A
> a -&gt; <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:unsafeSTToIO"
><A NAME="v%3AunsafeSTToIO"
></A
></A
><B
>unsafeSTToIO</B
> ::  <A HREF="Control-Monad-ST.html#t%3AST"
>ST</A
> s a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> a</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.4.2</TD
></TR
></TABLE
></BODY
></HTML
>