[Haskell-beginners] Using StateT with List monad
Ozgur Akgun
ozgurakgun at gmail.com
Sat Nov 24 16:57:10 CET 2012
Hi,
On 24 November 2012 15:15, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> twoSucc :: StateT Int [] ()
> twoSucc = do
> i <- get
> put (i+1) `mplus` put (i+2)
>
Another way of doing the same thing, which I find more intuitive, is the
following:
twoSucc :: StateT Int [] ()
twoSucc = do
i <- get
j <- lift [i+1, i+2]
put j
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121124/6e4d8149/attachment.htm>
More information about the Beginners
mailing list