[Haskell-cafe] Polymorphic algebraic type constructors
duncan.coutts at worcester.oxford.ac.uk
Tue Jun 22 16:09:41 EDT 2004
On Tue, 2004-06-22 at 20:52, Adrian Hey wrote:
> On Tuesday 22 Jun 2004 6:20 pm, MR K P SCHUPKE wrote:
> > ahh but in this example:
> > f :: [Int] -> [Bool]
> > f (i:is) = even i : f is
> > f e@ = e
> > e is an empty list of Ints not an empty list of Bools!
> If the difference is significant (I don't believe it is)
> then consistency demands that this expression should
> give a type error..
> let e= in (length e : e, null e : e)
> It doesn't, so clearly e can be both an empty list of
> Ints and an empty list of Bools :-)
I think the point is that  (or e in your example) has type
where as in the original example e was bound to an argument with the
type [Int], so e could not be used where something of type [Bool] was
required. On the other hand
 :: forall a.[a]
could be used in either context.
More information about the Haskell-Cafe