7

GHC's Core data type represents recursion with recursive binders in the Let constructor; as I understand it, all let expressions in Haskell are effectively let rec expressions. Why does GHC use this method of representing recursion instead of an atomic fixpoint operator?

2
  • Why shouldn't it?
    – cHao
    Commented Apr 30, 2018 at 15:03
  • 1
    Not sure why GHC specifically does this, but I’ll take a wild guess that it’s just about making it convenient to implement efficiently. If you have let ones = 1 : ones you can compile it directly to something like ones = { push ones; push 1; jump (:) }, while with the desugared version, let ones = fix (\ self -> 1 : self), you have to recognise that you can inline the lambda and avoid the allocation of a thunk for the application of the lambda to its own application. Presumably it’s also more convenient to work with a group of recursive let bindings than the same in terms of fix.
    – Jon Purdy
    Commented May 8, 2018 at 18:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.