WIP: Remove nested bracket restriction
This patch removes the nested bracket restriction by implementing cross-stage persistence for nested brackets.
There are two main points of interest
-
The bulk of the patch is adding a new constructor to represent brackets to the
template-haskellAST.BrackErepresents bracket forms. The idea is that for nested brackets we need to represent brackets, and after renaming, the form we have toHsRnBracketOutwhich has splices removed and an explicit environment. -
The implementation of
checkCrossStageLiftingis simplified so that we create aLHsExpr GhcPswhich we can pass intornExprso that splices are handled uniformly.
The only change from the previous implementation here is to generalise the lifting from 1 to n levels. Previously we would lift
by inserting the equivalent to $(lift x). For n levels we interpret the variable as $^n(lift^n x). So if we need to lift a variable x from level 0 to level 2, we create the syntax $($(lift (lift x))
This only works for untyped expression brackets so far and is placed here for preliminary review and CI.