declaring a generic type in type synonyms

Pixel pixel@mandrakesoft.com
21 Feb 2002 21:06:28 +0100


"Andre W B Furtado" <awfurtado@uol.com.br> writes:

> Is is possible to declare a generic type without using "data" or "newtype"?
> For example, I woud like that "pair" is a type synonym for "(t,t)" where t
> is a generic type, but just saying:
> 
> > type pair = (t,t)
> 
> won't work: i get a parse error.

- types in haskell must be capitalized (maybe a better syntax error message
would be nice, i ran into the same pb)

- "t" is a free variable, so you can't write this. Either write:

type Pair t = (t,t)
or
type Pair = (Int,Int)
or even
type Pair t1 t2 = (t1, t2)