[Haskell-cafe] Need Control.Monad.State

michael rice nowgate at yahoo.com
Tue Jul 27 22:39:52 EDT 2010

How do I import Control.Monad.State?

I see this note in http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State
Note: in some package systems used for GHC, the Control.Monad.State module is in a separate package, usually indicated by MTL (Monad Transformer Library).


===============rand.hs ==============

import Control.Monad.State

type GeneratorState = State StdGen

rollDie :: GeneratorState Int
rollDie = do generator <- get
             let( value, newGenerator ) = randomR (1,6) generator
             put newGenerator
             return value


[michael at localhost ~]$ ghci rand
GHCi, version 6.12.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.

    Could not find module `Control.Monad.State':
      Use -v to see a list of the files searched for.
Failed, modules loaded: none.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100727/b19bd2d0/attachment.html

More information about the Haskell-Cafe mailing list