[Haskell-beginners] Monadic Project Euler 1
Ozgur Akgun
ozgurakgun at gmail.com
Fri Feb 18 11:46:22 CET 2011
On 17 February 2011 21:02, Javier M Mora <jamarier at gmail.com> wrote:
> Yes, I'm trying to learn/practice Design Patterns in Haskell making euler
> problems three times:
>
> 1. Non Monad
> 2. Ad-hoc Monad
> 3. Standard Monad
>
> Thank you for help me in the 3rd Stage. I was trying to solve 2nd Stage.
> :-(
>
Sorry for jumping over one of the stages then :)
For this problem though, I can't see what the semantics of your ad-hoc monad
would be. You'll end up reimplementing a state monad, I suppose. If so, you
can always check the definition of the "standard" state monad:
http://hackage.haskell.org/packages/archive/mtl/1.1.1.1/doc/html/Control-Monad-State-Lazy.html#g:1
http://hackage.haskell.org/packages/archive/mtl/1.1.1.1/doc/html/src/Control-Monad-State-Lazy.html#State
(Disclaimer: This one is mtl-1, in mtl-2 there is no State monad. There is
the StateT monad transformer, whose Monad instance declaration might be a
bit harder to get a grasp of, and State s is a type alias to StateT s
Identity)
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110218/0fcb19ff/attachment.htm>
More information about the Beginners
mailing list