[Haskell-beginners] State monad

Ozgur Akgun ozgurakgun at gmail.com
Mon Feb 14 19:44:32 CET 2011


In the latest version of mtl, there is no State data constructor.

http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html#g:2

State<http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#t:State>is
defined to be a type alias to the application of Identity monad to the
StateT monad transformer.

As you've already discovered, you need to use
state<http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#v:state>
 instead.

HTH,

Ozgur

On 14 February 2011 18:11, 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
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110214/59926f80/attachment.htm>


More information about the Beginners mailing list