[Haskell-cafe] Re: A question about mfix

Luke Palmer lrpalmer at gmail.com
Wed Jul 30 01:38:06 EDT 2008


On Wed, Jul 30, 2008 at 4:18 AM, Wei Hu <weihu at cs.virginia.edu> wrote:
> Thanks for pointing out the sharing part. My original question is still
> unanswered: for lazy monads, can we give such a general mfix definition?

I dunno.  I played around with your definition and the mfix laws, and
was unable to get anywhere.

  * mfix (return . h) = return (fix h)

  * mfix (\x -> a >>= \y -> f x y) = \y -> mfix (\x -> f x y)

  * if h is strict,  mfix (liftM h . f) = liftM h (mfix (f . h))

  * mfix (\x -> mfix (\y -> f x y)) = mfix (\x -> f x x)

But I think this is the way to approach it.  There are many kinds of
"lazy monads", so presumably an exploration of this form will help
characterize the kinds of monads for which this definition does work.

Luke


More information about the Haskell-Cafe mailing list