Open jgbm opened 2 years ago
The GHC parser doesn't seem to include support for constraints on type synonym declarations, so I don't think actually supporting them is a top priority.
Maybe I misunderstood this comment.
did you mean to say type Num a => Point a = (a, a)
Actually they are okay with elaboration: atleast in GHC-9.
~~We now elaborate the type synonyms as follows:
type T a = U
get elaborated to
type T a = wft(U) => U
~~
We also perform some optimization where if wft(U)
is ()
then we get a identity elaboration.
consider the following declarations
data Ord a => T a = ...
type T a = DT a
f :: ... -> T a -> ...
we elaborate the type signature of f
to be
f :: DT @ a => ... -> T a -> ...
I don't think we need to generate a special type family X_T a :: Constraint
for each type synonym that we encounter. We can get away with expanding the RHS of the type and then generating the constraints to be added to the original type and thus constraining the use of of T
.
Inlining terms with type synonyms are no longer are an issue. I suspect this was an issue when we had disabled type reduction.
The GHC parser doesn't seem to include support for constraints on type synonym declarations, so I don't think actually supporting them is a top priority.
Marking this as low priority as not having constraint type synonyms is not going to break our work.
While we're thinking about #3, we should be sure that type synonyms don't give another route to an ill-kinded type. Something like:
There's also a historical detail here: the first version of the Haskell report allowed you to write
but this was dropped from later versions of the report, as nobody knew how to implement it.
There's a similar approach to that for type families:
Type synonym declarationstype T a = U
should also generate declarationstype X_T a = wft(U)
T a
should be constrained byX_T a
.Inlining terms that have type as type synonyms sometimes fails. (ref. in Cabal,#~
unfolding in functionliftOptionL
)