[Haskell-cafe] Re: Haskell Cheat Sheet?
ChrisK
haskell at list.mightyreason.com
Wed Sep 26 01:05:15 EDT 2007
I disagree -- see below
Dan Weston wrote:
> 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).
>
> Dan Weston
>
Useful counterexample:
-- import Data.Function(fix)
fix :: (t -> t) -> t
fix f = let f' = f f' in f'
one :: [Int] -> [Int]
one = (1:)
ones = [Int]
ones = fix one
This emphasizes that Haskell's fix can define non-function types, which the Y
combinator in strict languages is not useful for. (Unless someone would like to
correct me...)
--
Chris
More information about the Haskell-Cafe
mailing list