[Haskell-cafe] questions on lazy pattern, StateT monad

Fan Wu wufan9418 at gmail.com
Thu Nov 24 15:19:47 EST 2005

> But I think the reasons behind lazy pattern usage in the mplus
> implementation are similar to those behind lazy pattern usage in the (>>=)
> implementation.

I find the explanation of "Lazy patterns are useful in contexts where
infinite data structures are being defined recursively" is easier to
understand. Actually all the lazy pattern examples I have seen so far
belong to this category. Here I want to correct a statement I made
previously about:

  mplus m1 m2       = do  ...
                        ~(a,s') <- lift (mplus m1' m2')

In one of my emails to the thread I mentioned m1/m2 and m1'/m2' could
be different Monads so mplus works differently (so that this is not
exactly a recusrive data structure), but even so the lazy pattern
works. The problem is when m1/m2 and m1'/m2' are of the same Monad
type, then the problem of recursive definition comes up and this is
the place lazy patterns are particularly useful.


More information about the Haskell-Cafe mailing list