The key issue in Lennart's example, I think, is monomorphic recursion.
For the function
f _ =
let y = f 'a'
in undefined
Haskell incorrectly (IMHO) infers the type `f :: Char -> a'
instead of the more general type `f :: b -> a'.
This occurs because in the absense of type declarations,
Haskell assumes that any recursion will be monomorphic,
which is in general not necessarily the case.
Interestingly, the Mercury typechecker behaves differently
for the equivalent example: it infers the more general type.
I consider the fact that you can construct examples like
the one that Lennart showed to be a wart in Haskell,
and I'm quite pleased that Mercury doesn't exhibit the
same wart.
On a related topic, I think there's nothing wrong with having a type
system in which some expressions don't have a principle type. However,
in such situations, where there is no type declaration and there is no
principle type, then I think the type checker ought to complain of
ambiguity rather than going ahead and inferring a type which might be
too specific. If the type inference always infers the most general type,
or complains of ambiguity if it can't, then it's possible to preserve
the desirable property that adding type declarations won't change the
program's behaviour.
--
Fergus Henderson <[EMAIL PROTECTED]> | "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh> | but source code lives forever"
PGP: finger [EMAIL PROTECTED] | -- leaked Microsoft memo.