-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
DLamCasesE
, deprecate DLamE
/DCaseE
This patch deprecates the `DLamE` and `DCaseE` data constructors of `DExp` in favor of a new `DLamCasesE` data constructor, which represents `\cases` expressions. Moreover, `th-desugar` now desugars all lambda, `case`, `\case`, and `\cases` expressions to `DLamCasesE`. There are several reasons why this is desirable, but an especially important motivation for switching is to support desugaring expressions that use embedded type patterns (see #204) or invisible type patterns (see #205) in lambda, `case`, `\case`, and `\cases` expressions. This is a pretty big change, even by `th-desugar` standards. As such, I have made an effort to avoid some of the more extreme breaking changes for now. For example, I have refrained from removing `DLamE` and `DCaseE` outright, instead converting them to deprecated pattern synonyms. I have also introduced combinators such as `dLamE` and `dCaseE`, which construct lambda-like and `case`-like expressions in terms of `DLamCasesE`. For the full details on how to migrate your code over to use `DLamCaseE`, see the new `doc/LambdaCaseMigration.md` document. This patch: * Fixes #210 (by replacing `DLamE`/`DCaseE` with `DLamCasesE`) * Fixes #204 (by supporting higher-order uses of embedded type patterns) * Fixes #205 (for supporting higher-order uses of invisible type patterns) This also adds regression tests for #204 and #205.
- Loading branch information
1 parent
785fb59
commit a3a73a2
Showing
10 changed files
with
799 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,8 @@ [email protected] | |
|
||
module Language.Haskell.TH.Desugar ( | ||
-- * Desugared data types | ||
DExp(..), DLetDec(..), NamespaceSpecifier(..), DPat(..), | ||
DExp(..), pattern DLamE, pattern DCaseE, | ||
DLetDec(..), NamespaceSpecifier(..), DPat(..), | ||
DType(..), DForallTelescope(..), DKind, DCxt, DPred, | ||
DTyVarBndr(..), DTyVarBndrSpec, DTyVarBndrUnit, Specificity(..), | ||
DTyVarBndrVis, | ||
|
@@ -100,7 +101,8 @@ module Language.Haskell.TH.Desugar ( | |
getDataD, dataConNameToDataName, dataConNameToCon, | ||
nameOccursIn, allNamesIn, flattenDValD, getRecordSelectors, | ||
mkTypeName, mkDataName, newUniqueName, | ||
mkTupleDExp, mkTupleDPat, maybeDLetE, maybeDCaseE, mkDLamEFromDPats, | ||
mkTupleDExp, mkTupleDPat, maybeDLetE, maybeDCaseE, maybeDCasesE, | ||
dCaseE, dCasesE, dLamE, dLamCaseE, mkDLamEFromDPats, | ||
tupleNameDegree_maybe, | ||
unboxedSumNameDegree_maybe, unboxedTupleNameDegree_maybe, | ||
isTypeKindName, typeKindName, bindIP, | ||
|
@@ -234,7 +236,7 @@ flattenDValD (DValD pat exp) = do | |
y <- newUniqueName "y" | ||
let pat' = wildify name y pat | ||
match = DMatch pat' (DVarE y) | ||
cas = DCaseE (DVarE x) [match] | ||
cas = dCaseE (DVarE x) [match] | ||
return $ DValD (DVarP name) cas | ||
|
||
wildify name y p = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.