[Haskell-cafe] Haskell Cheat Sheet?

Jonathan Cast jcast at ou.edu
Wed Sep 26 11:39:22 EDT 2007


On Tue, 2007-09-25 at 17:19 -0700, Dan Weston wrote:
> One suggestion:
> 
> Section 3.6 defines a function "fix":
> 
>   fix :: Eq x => (x -> x) -> x -> x
> 
>   fix f x = if x == x' then x else fix f x'
>       where x' = f x
> 
> This confusingly differs in both type and meaning from the traditional 
> function Control.Monad.Fix.fix and is not even used elsewhere in the 
> document.
> 
> I suggest that it be removed and the real Control.Monad.Fix.fix function 
> be defined in its own section, with an side-by-side comparison with a 
> named recursive function. This would be useful because the type
> 
> fix :: (a -> a) -> a
> 
> is highly confusing, suggesting to newcomers a usage like:
> 
> f = fix (+1)
> 
> which is undefined (and seems to be "missing an argument"), when 
> invariably its type is in practice restricted to:
> 
> fix :: ((a -> b) -> (a -> b)) -> (a -> b)
> 
> which is much more suggestive (but nowhere to be found in the docs).

Not invariably.  I frequently use fix at monadic types, sometimes with
an argument but not always.

jcc




More information about the Haskell-Cafe mailing list