Skip to content

Definition of fix lacks commentary

In Data.Function,

fix :: (a -> a) -> a
fix f = let x = f x in x

It is not immediately obvious why it is defined like this, rather than the more natural

fix f = f (fix f)

There are very good reasons for this; notably, it allows for the definition of circular data structures. But there should be a comment explaining this, preferably in the Haddocks.

Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Core Libraries
Test case
Differential revisions
BlockedBy
Related
Blocking
CC core-libraries-committee@haskell.org
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information