[Haskell-cafe] Polymorphic algebraic type constructors
ahey at iee.org
Wed Jun 23 07:22:09 EDT 2004
On Wednesday 23 Jun 2004 10:46 am, MR K P SCHUPKE wrote:
> >f (i:is) = even i : f is
> >f e = e
> This still makes perfect sense to me... you see the let binding:
> let e@ = e
> has no additional information about the type of  so it must be fully
> if the function binding we know typeOf e == typeOf (i:is) and that
> i is a member of the class Integral (from the application of even)
> As we always take the most precise available type we end up with
> forall a. Integral a => [a]
> as the type for 'e'... Now Bool is not a member of Integral so
> it is a type error!
It's only a type error because Haskell currently defines it as such.
It's not a type error in the sense that programs which were typed the
way I suggest would cause a runtime error.
As for the issue of resolving overloading ambiguities, there is indeed
a distinction between an empty list of Ints and an empty list of Bools.
There should not be IMO.
IIRC this issue is what lead Fergus Henderson to describe what what I
was proposing as a hack, all those years ago. Though personally I regard
it as evidence that Haskells overloading mechanisms, as currently implemented,
are a hack :-)
More information about the Haskell-Cafe