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 in RULES, and explicit foralls in type family instances. Correspondingly,

      • There is now a DAppKindT constructor in DType.
      • Previously, the DDataInstD constructor had fields of type Name and [DType]. Those have been scrapped in favor of a single field of type DType, representing the application of the data family name (which was previously the Name) to its arguments (which was previously the [DType]).

      DDataInstD also has a new field of type Maybe [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 type DType, representing the application of the type family name (which DTySynEqn did not used to contain!) to its arguments (which was previously the [DType]).

      DTySynEqn also has a new field of type Maybe [DTyVarBndr] to represent its explicitly quantified type variables (if present).

      • DTySynInstD no longer has a field of type Name, as that is redundant now that each DTySynEqn contains the same Name.
      • There is now a field of type Maybe [DTyVarBndr] in the DRuleP constructor to represent bound type variables in RULES (if present).
    • โž• Add a field of type Maybe [DTyVarBndr] to DInstanceD and DStandaloneDerivD for optionally quantifying type variables explicitly. If supplied with a Just, this sweetens the instance type to use a ForallT to represent the explicit quantification. This trick is not supported for InstanceD on GHC 8.0 and for StandaloneDerivD on GHC 7.10 or 8.0, so be aware of this limitation if you supply Just 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 to IP "x" a => ....
      • id ?x is desugared to id (ip @"x").
      • let ?x = 42 in ... is desugared to let new_x_val = 42 in bindIP @"x" new_x_val ... (where bindIP is a new utility function exported by Language.Haskell.TH.Desugar on GHC 8.0 or later).

    In order to support this desugaring, the type signatures of dsLetDec and dsLetDecs now return ([DLetDec], DExp -> DExp) instead of just [DLetDec], where DExp -> 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 the id function.)

    • ๐Ÿ›  Fix a bug in which toposortTyVarsOf would error at runtime if given types containing foralls 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 in foralls.
    • ๐Ÿ›  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 of Names generated with qNewName.
    • 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 to DType. This also means that the DPat constructors, which previously ended with the suffix Pa, can now use the suffix P, mirroring TH.
    • The type of applyDType has changed from DType -> [DType] -> DType to DType -> [DTypeArg] -> DType, where DTypeArg is a new data type that encodes whether an argument is a normal type argument (e.g., the Int in Maybe Int) or a visible kind argument (e.g., the @Type in Proxy @Type Char). A TypeArg data type (which is like DTypeArg, but with Types/Kinds instead of DTypes/DKinds) is also provided.

    A handful of utility functions for manipulating TypeArgs and DTypeArgs are also exported.

    • ๐Ÿ†“ th-desugar functions that compute free variables (e.g., fvDType) now return an OSet, a variant of Set 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.