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-haskell
AST.BrackE
represents bracket forms. The idea is that for nested brackets we need to represent brackets, and after renaming, the form we have toHsRnBracketOut
which has splices removed and an explicit environment. -
The implementation of
checkCrossStageLifting
is simplified so that we create aLHsExpr GhcPs
which we can pass intornExpr
so 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.