On 17 February 2011 21:02, Javier M Mora
<jamarier@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:
(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