[Haskell-cafe] Polymorphic algebraic type constructors

Adrian Hey ahey at iee.org
Wed Jun 23 08:35:37 EDT 2004


On Wednesday 23 Jun 2004 12:40 pm, MR K P SCHUPKE wrote:
> What you are suggesting - whilst it seems reasonable requires
> a fundamental change to the type system. At the moment []
> signifies an empty list of type 'a' ... what you are suggesting
> requires [] to have a different type from [a]... This means
> a simple case statement :
>
>         case a of
>                 (a:as) ->
>                 [] ->
>
> would now not type because everything on the LHS of the cases must
> be the same type.
>
> Infact I don't see how it could be any other way... 'a' has a type
> call it [a]... how could [] be any other type?

I think all occurences of [] have type forall a. [a]
The case expression..
         case a of
                 (a':as) -> <expr1>
                 []      -> <expr2>

Should be typed as if written..
         case a of
                 (a':as) -> let a=(a':as) in <expr1>
                 []      -> let a=[]      in <expr2>

Regards
--
Adrian Hey



More information about the Haskell-Cafe mailing list