Are type variables in GADT heads meaningful?

Is there a difference between the two GADT ads?

data A ab where ... data A :: * -> * -> * where ... 
+8
syntax haskell gadt
source share
1 answer

There is no difference. You might think that you do not need to mention type variables in the header to use different names for them in constructor signatures, for example:

 data A :: * -> * -> * where AN :: Num x => x -> b -> A xb AS :: IsString s => s -> b -> A sb 

However, as the GHC User Guide says ...

Unlike a Haskell-98 type data type declaration, a variable of type (s) in the data Set a where header has no scope.

... and therefore this also works:

 data A ab where AN :: Num x => x -> b -> A xb AS :: IsString s => s -> b -> A sb 
+8
source share

All Articles