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.
Generalize functions for binders, support general patterns (see #16)
Add
withPattern
method toCoSinkable
. It can be seen as a CPS-style traversal over binders in a pattern.Our Template Haskell support covers generation of
withPattern
,so normally the user does not have to think about it.
Generalize many functions to work with arbitrary patterns, not just
NameBinder
:withFreshPattern
— towithRefreshedPattern
andwithRefreshedPattern'
extendScopePattern
— extend a given scope with all binders in a given patternnamesOfPattern
— collect all names from a patternunsinkNamePattern
— try to unsink names from a scope extended with binders from a given patternassertDistinctPattern
— establish that extended scope is distinct (if outer scope is)assertDistinctExt
— establish that extended scope is distinct and indeed an extensionImplement unification for patterns in
unifyPatterns
.This turns out to be one of the most difficult places, especially for compound patterns.
Implementing patterns properly on the user side not comfortable at all!
Luckily, we provide useful helpers like
andThenUnifyPatterns
andandThenUnifyNameBinders
,as well as Template Haskell support to derive
UnifiablePattern
.Generalize Free Foil to support arbitrary patterns.
The
Foil
andFreeFoilTH
implementations now make use of the generalized pattern support.