
Actually, I can load the module and I have mtl. I just don't understand why
I can use State as a data constructor, but the inverse of runState, i.e.
state works just fine. Has this library/package been reconfigured from when
most people were writing tutorials?
On Mon, Feb 14, 2011 at 1:19 PM, Mihai Maruseac
On Mon, Feb 14, 2011 at 8:18 PM, Mihai Maruseac
wrote: On Mon, Feb 14, 2011 at 8:11 PM, Britt Anderson
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
Also, see if you have the mtl library installed (or Transformers).
-- Mihai