[Haskell-cafe] Feeding a monad into itself

MarLinn monkleyon at gmail.com
Fri Jul 21 21:16:02 UTC 2017

> Very interesting! What do you mean by a "better" unfold?
Well you asked the original question, so I'll leave that up to you to 
define. ;)

Your original version is relatively specialised, but simple and 
efficient. The one I adapted uses quite a bit of intermediate wrapping 
and unwrapping and needs to move parts around on every iteration. Only 
because of list fusion does it have a chance to compete. It's also quite 
indirect and uses up cognitive energy when trying to understand it. So 
yours is "better" in several ways.

Maybe there's a general unfold that is easier to understand. Or more 
efficient. Or easier to adapt to more situations. It depends highly on 
what your actual goals areā€¦

More information about the Haskell-Cafe mailing list