On 9/15/06, Robert Dockins <[EMAIL PROTECTED]> wrote:
You can define a direct fixed point combinator
without relying on nominal recursion in Haskell, but it requires you to
define a helper newtype.

That's really nifty!  I'd been wondering whether you could do this
too.  Is there a reason for the extra `z' parameter?

Don't run this in GHC because it will diverge.  Hugs works, however.

According to

http://www.haskell.org/pipermail/glasgow-haskell-bugs/2001-August/001717.html

this is due to a bug in the GHC inliner that probably won't be fixed.
However, experimentation indicates you can work around the bug using
the NOINLINE pragma:


newtype Mu a = Roll { unroll :: Mu a -> a }

fix :: (a -> a) -> a
fix f = doink (Roll doink)
   where {-# NOINLINE doink #-}
         doink x = f ((unroll x) x)


Mike
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to