
Description
There is a discrepancy between the way instances of type families and type classes are represented in HSE.
data Decl l
...
So far so good.
...
| TypeInsDecl l (Type l) ...
| DataInsDecl l ... (Type l) ...
| GDataInsDecl l ... (Type l) ...
...
This is a very broad type, which is not too type-safe, but it might be handy for some applications to have an instance head to be presented like this.
...
| InstDecl l (Maybe (Context l)) (InstHead l) ...
| DerivDecl l (Maybe (Context l)) (InstHead l)
...
This is a much narrower type, but at least we can be sure that the type will be like C t1 .. tn
, which is helpful in certain situations. However, it's currently too narrow and it causes problems (see #9), so it should perhaps include (Maybe [TyVarBind l])
. It might even be useful to absorb these two fields into the InstHead
data type.
For Language.Haskell.Exts.Syntax
it's worse.
data Decl
...
| TypeInsDecl SrcLoc Type ...
| DataInsDecl SrcLoc ... Type ...
| GDataInsDecl SrcLoc ... Type ...
...
For type families, nothing really changes.
...
| InstDecl SrcLoc Context QName [Type] ...
| DerivDecl SrcLoc Context QName [Type]
...
For type classes, there isn't even an InstHead
data type.
I suggest that all these cases should be turned into one encoding, be it Type
s or InstHead
s. In my opinion, InstHead
is the most HSE-ish approach here.