BSD-3-Clause licensed and maintained by Richard Eisenberg
This version can be pinned in stack with:th-desugar-1.4.2@sha256:1ec55cb7234a4e2b229484198407fc76df4b40512df6097b07ae252a0c522b32,2483

Module documentation for 1.4.2

  • Language
    • Language.Haskell
      • Language.Haskell.TH
        • Language.Haskell.TH.Desugar
          • Language.Haskell.TH.Desugar.Expand
          • Language.Haskell.TH.Desugar.Lift
          • Language.Haskell.TH.Desugar.Sweeten
Used by 1 package in lts-0.7(full list with versions):

th-desugar Package

Build Status

This package provides the Language.Haskell.TH.Desugar module, which desugars Template Haskell’s rich encoding of Haskell syntax into a simpler encoding. This desugaring discards surface syntax information (such as the use of infix operators) but retains the original meaning of the TH code. The intended use of this package is as a preprocessor for more advanced code manipulation tools. Note that the input to any of the ds... functions should be produced from a TH quote, using the syntax [| ... |]. If the input to these functions is a hand-coded TH syntax tree, the results may be unpredictable. In particular, it is likely that promoted datatypes will not work as expected.

One explicit goal of this package is to reduce the burden of supporting multiple GHC / TH versions. Thus, the desugared language is the same across all GHC versions, and any inconsistencies are handled internally.

The package was designed for use with the singletons package, so some design decisions are based on that use case, when more than one design choice was possible.

I will try to keep this package up-to-date with respect to changes in GHC.


Version 1.4.2

  • expand functions now consider open type families, as long as the type to be expanded has no free variables.

Version 1.4.1

  • Added Language.Haskell.TH.Desugar.Lift, which provides Lift instances for all of the th-desugar types, as well as several Template Haskell types.

  • Added applyDExp and applyDType as convenience functions.

Version 1.4.0

  • All Decs can now be desugared, to the new DDec type.

  • Sweetening Decs that do not exist in GHC 7.6.3- works on a “best effort” basis: closed type families are sweetened to open ones, and role annotations are dropped.

  • Infos can now be desugared. Desugaring takes into account GHC bug #8884, which meant that reifying poly-kinded type families in GHC 7.6.3- was subtly wrong.

  • There is a new function flattenDValD which takes a binding like let (a,b) = foo and breaks it apart into separate assignments for a and b.

  • There is a new Desugar class with methods desugar and sweeten. See the documentation in Language.Haskell.TH.Desugar.

  • Variable names that are distinct in desugared code are now guaranteed to have distinct answers to nameBase.

  • Added a new function getRecordSelectors that extracts types and definitions of record selectors from a datatype definition.

Version 1.3.1

  • Update cabal file to include testing files in sdist.

Version 1.3.0

  • Update to work with type Pred = Type in GHC 7.9. This changed the DPred type for all GHC versions, though.

Version 1.2.0

  • Generalized interface to allow any member of the Qausi class, instead of just Q.

Version 1.1.1

  • Made compatible with HEAD after change in role annotation syntax.

Version 1.1

  • Added module Language.Haskell.TH.Desugar.Expand, which allows for expansion of type synonyms in desugared types.
  • Added Show, Typeable, and Data instances to desugared types.
  • Fixed bug where an as-pattern in a let statement was scoped incorrectly.
  • Changed signature of dsPat to be more specific to as-patterns; this allowed for fixing the let scoping bug.
  • Created new functions dsPatOverExp and dsPatsOverExp to allow for easy desugaring of patterns.
  • Changed signature of dsLetDec to return a list of DLetDecs.
  • Added dsLetDecs for convenience. Now, instead of using mapM dsLetDec, you should use dsLetDecs.

Version 1.0

  • Initial release