Adapt to DLamCasesE
in th-desugar-1.18
#595
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch bumps the pinned
th-desugar
commit to bring in the changes from goldfirere/th-desugar#218, which replacesDLamE
andDCaseE
in favor ofDLamCasesE
. Quite happily, this actually simplifies how singling works insingletons-th
. Previously, we went through great efforts to annotate promotedcase
expressions with their overall return type, as described inNote [Annotate case return type]
andNote [The id hack; or, how singletons-th learned to stop worrying and avoid kind generalization]
inD.S.TH.Single
. After this patch, however, allcase
expressions are desugared to\cases
expressions, and because we already annotate singled\cases
expressions (by generating code likesingFun1 @LamCasesSym0 (\cases ...)
), we no longer need to use the tricks describes in those two Notes. Hooray!One interesting knock-on effect of these simplifications is that given code like this:
singletons-th
would previously generate code that looked like this:Unlike the original code, this singled code would compile without warnings. This is because
sX
is "used" in the sense that it is passed to acase
expression. It's a very sillycase
expression, as it doesn't do anything meaningful withsX
, but it still technically counts as a use.Now that
singletons-th
uses a\cases
-based approach to singling, however, the singled code will instead look like this:This time, GHC does recognize that
sX
is unused and emits a warning. This actually affects the way thatsingletons-th
generates code for derivedFunctor
andFoldable
instances, so I needed to generate wildcard patterns instead of variable patterns in certain parts ofD.S.TH.Promote.Deriving.{Functor,Foldable}
. I have also mentioned the possibility ofsingletons-th
generating more warnings in theCHANGELOG
.