What's wrong about giving mfix the following general definition? 

>  mfix :: (a -> m a) -> m a 
>  mfix f = (mfix f) >>= f 


I know it diverges if (>>=) is strict on the first argument. My 
question is, is this definition correct for all lazy monads? The 
documentation (http://haskell.org/ghc/docs/latest/html/libraries/base/ 
Control-Monad-Fix.html#v%3Amfix) says "mfix f executes the action f 
only once, with the eventual output fed back as the input.". So my 
definition looks like a valid one, doesn't it? 

I haven't fully wrapped my head around this monadic fixed-point thing 
yet. So, if you can give an example showing how my definition differs 
from a standard monad, that'll be great. 

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to