-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace DLamE
/DCaseE
with lambda cases (\cases
)
#210
Comments
This is a partial fix for #204 which adds `DTypeE` and `DTypeP` constructs to the `th-desugar` AST, which behave exactly like their `TypeE` and `TypeP` counterparts in the `template-haskell` AST. This is only a partial fix, however, because `DTypeP` is currently only supported in the clauses of function declarations. In particular, `DTypeP` is _not_ supported in lambda expressions, `\case` expressions, or `\cases` expressions. See the "Known limitations" section of the `README` for more. In order to add full support for `DTypeP`, we would first need to implement the design proposed in #210. Until then, this is good enough.
This is a partial fix for #205 which adds a `DInvisP` data constructor to `DPat`, which behaves exactly like `InvisP` in the `template-haskell` AST. This is only a partial fix, however, because `DInvisP` is currently only supported in the clauses of function declarations. In particular, `DInvisP` is _not_ supported in lambda expressions or `\cases` expressions. See the "Known limitations" section of the `README` for more. In order to add full support for `DInvisP`, we would first need to implement the design proposed in #210. Until then, this is good enough.
This is a partial fix for #204 which adds `DTypeE` and `DTypeP` constructs to the `th-desugar` AST, which behave exactly like their `TypeE` and `TypeP` counterparts in the `template-haskell` AST. This is only a partial fix, however, because `DTypeP` is currently only supported in the clauses of function declarations. In particular, `DTypeP` is _not_ supported in lambda expressions, `\case` expressions, or `\cases` expressions. See the "Known limitations" section of the `README` for more. In order to add full support for `DTypeP`, we would first need to implement the design proposed in #210. Until then, this is good enough.
This is a partial fix for #205 which adds a `DInvisP` data constructor to `DPat`, which behaves exactly like `InvisP` in the `template-haskell` AST. This is only a partial fix, however, because `DInvisP` is currently only supported in the clauses of function declarations. In particular, `DInvisP` is _not_ supported in lambda expressions or `\cases` expressions. See the "Known limitations" section of the `README` for more. In order to add full support for `DInvisP`, we would first need to implement the design proposed in #210. Until then, this is good enough.
One obstacle to making this work is that \cases
True (Just x) -> x
False Nothing -> 2
_ _ -> 3 Note that you wouldn't actually be able to write such an expression directly with a pre-9.4 version of GHC—you'd only be able to construct one by splicing in a
For now, I am inclined to pick option (1). We can revisit if someone specifically asks for the ability to sweeten |
Reading the options, I was more excited about (3). But actually I agree that (1) is most expedient. |
LamE
/CaseE
with lambda cases (\cases
)DLamE
/DCaseE
with lambda cases (\cases
)
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.
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.
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.
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.
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.
See #218 for the changes on the |
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.
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.
Currently, the
th-desugar
AST has aDLamE
construct for binding variables in expressions, and aDCaseE
construct for scrutinizing expressions. I propose that we remove both of these in favor of a singleDLamCasesE
construct, as proposed in #174 (comment):Advantages
Doing so would make the
th-desugar
AST more minimal, as we can desugar lambda expressions,case
expressions,\case
expressions, and\cases
expressions to a single language construct (DLamCasesE
). (See Add support for visibleforall
s in lambda,\case
, and\cases
expressions #204 (comment) for examples of how each of these desugarings would work.) We could also get rid ofDMatch
in favor ofDClause
.Doing so would avoid the need to desugar expressions like this:
Into this:
That is, it would avoid the need to "pack" arguments into an unboxed tuple just for the sake of pattern-matching on them in a single clause. Instead, we can avoid all of this tuple-packing business by simply using
\cases
' built-in pattern-matching capabilities.By not performing tuple-packing, we would make it much, much simpler to desugar expressions that bind embedded type patterns or invisible type patterns (Add support for visible
forall
s in lambda,\case
, and\cases
expressions #204).Potential downsides
th-desugar
standards. It may not be entirely straightforward to migrate all existingth-desugar
clients over to theDLamCasesE
approach, so we may even want to consider a deprecation period for one release before removingDLamE
andDCaseE
entirely.singletons-th
(by far the most sophisticatedth-desugar
client I know of) over to this new approach. We should make sure that this is viable before committing to this design.The text was updated successfully, but these errors were encountered: