[Haskell-cafe] Polymorphic algebraic type constructors

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Jun 23 05:46:55 EDT 2004

>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!


More information about the Haskell-Cafe mailing list