Skip to content

WIP: Remove nested bracket restriction

Matthew Pickering requested to merge mpickering/ghc:stage-n into master

This patch removes the nested bracket restriction by implementing cross-stage persistence for nested brackets.

There are two main points of interest

  1. 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 to HsRnBracketOut which has splices removed and an explicit environment.

  2. The implementation of checkCrossStageLifting is simplified so that we create a LHsExpr GhcPs which we can pass into rnExpr 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.

Edited by Matthew Pickering

Merge request reports