Fri Apr 13 14:29:47 CEST 2012
Stateful iteration (for / forM) or unfold?
In writing the layout engine, I run into a dilemma when writing loops.
Either I use a classical approach (for / forM) where all side effects
can be kept in a Monad or Applicative instance, or I work with a
combination of map/zip and unfold, where the "stateful" part is
The conclusion I tend to draw is that it doesn't matter much.
Sometimes it's just useful to perform unfold before map to have some
decoupling. Other times its simpler to combine iteration and state..
But if you can do one, you can of course do the other..