Monoid example
I was reading http://learnyouahaskell.com/a-fistful-of-monads, but felt that the moving multiple steps part could be made more flexible using
Monoid
, so here’s my attempt. The key is that given a step function, a -> [a]
, from the current state to multiple next states, how to make it a
monoid so that we can merge multiple into one.
1 | import Control.Monad |