[Haskell-beginners] Brainfuck interpreter stack overflow

Stephen Tetley stephen.tetley at gmail.com
Tue Jan 26 14:12:02 EST 2010

Hi Edgar

I'm not sure what a 'lawful' monad would be for your zipper, so I can
sympathize with the author of the package on Hackage who omitted one.
Monads have three laws which instances of the Monad class are obliged
to obey, but the language cannot check that they do (i.e the type
system can't check you obey them):


A text book on Haskell would cover the monad laws if it covers monads,
for instance in Paul Hudak's book they are on page 254.

For a more general zipper, Chung-chieh Shan has a monad:


However that monad looks very similar to a resumption monad
(resumption monads are commonly used to model concurrency as they can
pause computations and so yield to other threads). This seems
appropriate to a zipper - I think that Gerard Huet, the inventor of
the zipper, originally used it to move a cursor around a tree
structure within an interactive editor.

A quick web search reveals another one here, I've never looked at this
one before but it looks close to a state monad:


>From your definition, I suspect if you use GHCs deriving mechanism it
will make a quadruple list monad which will obviously compile and run
but doesn't seem appropriate.

Best wishes


More information about the Beginners mailing list