August 2011
2 posts
The practicality of the 'fix' combinator
In Control.Monad.Fix and Data.Function, there is a combinator function called fix. Its type is (a -> a) -> a. It is defined as:
fix f = let x = f x in x
but it could also be defined (maybe more clearly) as:
fix f = f (fix f)
It creates an infinite chain of the function, and it’s sometimes used to rewrite a recursive function. For example:
ones = 1:ones
is equivalent...
CSS or CSS not; there is no try.