[Haskell-cafe] Composing functions with runST

Yitzchak Gale gale at sefer.org
Tue Jan 2 05:25:40 EST 2007

Hi Thomas,

You wrote:
> How do I "import" Control.Monad.ST so I can experiment with it from
> ghci and just do
> runST
> like you had. Instead of qualifying it in some way.

In GHCi, use the :module command (:m) for built-in
modules, and :load and :add  for source files.

In Hugs, use :load and :also for both. You need to run Hugs
with the -98 flag to use Control.Monad.ST.

> how do I do runST as fully qualified?

Like this:

Prelude> Control.Monad.ST.runST (do {r <- Data.STRef.newSTRef 2007;
Data.STRef.readSTRef r})

Have fun with monads!


More information about the Haskell-Cafe mailing list