[Haskell-beginners] State monad

Mihai Maruseac mihai.maruseac at gmail.com
Mon Feb 14 19:18:16 CET 2011

On Mon, Feb 14, 2011 at 8:11 PM, Britt Anderson
<britt.uwaterloo at gmail.com> wrote:
> Many of the tutorials on the state monad seem to suggest that you can use
> State as a data constructor, but I can't get this to work. E.g. in ghci
> after :m Control.Monad.State I can
> let f = (\x -> (x,x))
> let y = state f
> but if I,
> let z = State f
> I get an error message: Not in scope: data constructor `State'.
> Can someone please explain?
> Thanks, Britt

GHCi doesn't load all Haskell modules by default. It only loads
Prelude. You'll have to load them by hand. Use

:m +Control.Monad.State


More information about the Beginners mailing list