Copyright | (c) 2001 - 2004 Wolfgang Lux Martin Engelke 2011 - 2015 Björn Peemöller 2015 Jan Tikovsky |
---|---|
License | BSD-3-clause |
Maintainer | bjp@informatik.uni-kiel.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Transformations.Desugar
Description
The desugaring pass removes all syntactic sugar from the module. In particular, the output of the desugarer will have the following properties.
- No guarded right hand sides occur in equations, pattern declarations, and case alternatives. In addition, the declaration lists (`where`-blocks) of the right hand sides are empty; local declarations are transformed into let expressions.
- Patterns in equations and case alternatives are composed only of
- literals,
- variables,
- constructor applications, and
- as patterns applied to literals or constructor applications.
- Expressions are composed only of
- literals,
- variables,
- constructors,
- (binary) applications,
- case expressions,
- let expressions, and
- expressions with a type signature.
- Applications 'N x' in patterns and expressions, where
N
is a newtype constructor, are replaced by ax
. Note that neither the newtype declaration itself nor partial applications of newtype constructors are changed. It were possible to replace partial applications of newtype constructor byid
. However, our solution yields a more accurate output when the result of a computation includes partial applications. - Functional patterns are replaced by variables and are integrated in a guarded right hand side using the (=:<=) operator.
- Records are transformed into ordinary data types by removing the fields. Record construction and pattern matching are represented using solely the record constructor. Record selections are represented using selector functions which are generated for each record declaration, and record updated are represented using case-expressions that perform the update.
- The type environment will be extended by new function declarations for:
- Record selections, and
- Converted lambda expressions.
As we are going to insert references to real prelude entities, all names must be properly qualified before calling this module.