[Haskell-cafe] Remember the future
paul at cogito.org.uk
Fri Aug 17 20:10:53 EDT 2007
jerzy.karczmarczuk at info.unicaen.fr wrote:
> Andrew Coppin writes:
>> I've seen comments in various places that monads allow you to "borrow
>> things from the future".
>> That sounds completely absurd to me... can anybody explain?
> Actually, "borrowing from the future" - in an interpretation which is
> to my own interests - doesn't need monads, but *laziness*.
While this is true, the "mdo" and associated MonadFix class do implement
it in a monadic framework where you can write things like
x <- f y
y <- g x
If you interpret do-notation as equivalent to imperative programming
then this does indeed look like time travel. Under the covers its more
x = f y
y = g x
which is also known as "tying the knot" or the "credit card transform"
(both keywords worth looking up).
However I can't say I really have my head around it properly.
More information about the Haskell-Cafe