th-desugar v1.10 Release Notes
-
- ๐ Support GHC 8.8. Drop support for GHC 7.6.
โ Add support for visible kind application, type variable
foralls
inRULES
, and explicitforall
s in type family instances. Correspondingly,- There is now a
DAppKindT
constructor inDType
. - Previously, the
DDataInstD
constructor had fields of typeName
and[DType]
. Those have been scrapped in favor of a single field of typeDType
, representing the application of the data family name (which was previously theName
) to its arguments (which was previously the[DType]
).
DDataInstD
also has a new field of typeMaybe [DTyVarBndr]
to represent its explicitly quantified type variables (if present).- Previously, the
DTySynEqn
constructor had a field of type[DType]
. That has been scrapped in favor of a field of typeDType
, representing the application of the type family name (whichDTySynEqn
did not used to contain!) to its arguments (which was previously the[DType]
).
DTySynEqn
also has a new field of typeMaybe [DTyVarBndr]
to represent its explicitly quantified type variables (if present).DTySynInstD
no longer has a field of typeName
, as that is redundant now that eachDTySynEqn
contains the sameName
.- There is now a field of type
Maybe [DTyVarBndr]
in theDRuleP
constructor to represent bound type variables inRULES
(if present).
- There is now a
โ Add a field of type
Maybe [DTyVarBndr]
toDInstanceD
andDStandaloneDerivD
for optionally quantifying type variables explicitly. If supplied with aJust
, this sweetens the instance type to use aForallT
to represent the explicit quantification. This trick is not supported forInstanceD
on GHC 8.0 and forStandaloneDerivD
on GHC 7.10 or 8.0, so be aware of this limitation if you supplyJust
for this field.โ Add support for desugaring implicit params. This does not involve any changes to the
th-desugar
AST, as:(?x :: a) => ...
is desugared toIP "x" a => ...
.id ?x
is desugared toid (ip @"x")
.let ?x = 42 in ...
is desugared tolet new_x_val = 42 in bindIP @"x" new_x_val ...
(wherebindIP
is a new utility function exported byLanguage.Haskell.TH.Desugar
on GHC 8.0 or later).
In order to support this desugaring, the type signatures of
dsLetDec
anddsLetDecs
now return([DLetDec], DExp -> DExp)
instead of just[DLetDec]
, whereDExp -> DExp
is the expression which binds the values of implicit params (e.g.,\z -> bindIP @"x" new_x_val z
) if any are bound. (If none are bound, this is simply theid
function.)- ๐ Fix a bug in which
toposortTyVarsOf
would error at runtime if given types containingforall
s as arguments. - ๐ Fix a bug in which
fvDType
would return incorrect results if given a type containing quantified constraints. - ๐ Fix a bug in which
expandType
would not expand type synonyms in the kinds of type variable binders inforall
s. - ๐ Fix a bug in which
getRecordSelectors
would omit record selectors from GADT constructors. - ๐ Fix a bug in which
toposortTyVarsOf
would sometimes not preserve the left-to-right ordering ofName
s generated withqNewName
. - Locally reified class methods, data constructors, and record selectors now quantify kind variables properly.
- Desugared ADT constructors now quantify kind variables properly.
- โ Remove
DPred
, as it has become too similar toDType
. This also means that theDPat
constructors, which previously ended with the suffixPa
, can now use the suffixP
, mirroring TH. - The type of
applyDType
has changed fromDType -> [DType] -> DType
toDType -> [DTypeArg] -> DType
, whereDTypeArg
is a new data type that encodes whether an argument is a normal type argument (e.g., theInt
inMaybe Int
) or a visible kind argument (e.g., the@Type
inProxy @Type Char
). ATypeArg
data type (which is likeDTypeArg
, but withType
s/Kind
s instead ofDType
s/DKind
s) is also provided.
A handful of utility functions for manipulating
TypeArg
s andDTypeArg
s are also exported.- ๐
th-desugar
functions that compute free variables (e.g.,fvDType
) now return anOSet
, a variant ofSet
that remembers the order in which elements were inserted. A consequence of this change is that it fixes a bug that causes free variables to be computed in different orders depending on which unique numbers GHC happened to generate internally. - Substition and type synonym expansion are now more efficient by avoiding
the use of
syb
in inner loops.