Note [Quotation and rebindable syntax]
Consider f = [| (* 3) |] Because of Note [Handling overloaded and rebindable constructs] in GHC.Rename.Expr, the renamer will expand (* 3) to (rightSection (*) 3), regardless of RebindableSyntax. Then, concerning the TH quotation, * If RebindableSyntax is off, we want the TH quote to generate the section (* 3), as the user originally wrote. * If RebindableSyntax is on, we perhaps want the TH quote to generate (rightSection (*) 3), using whatever 'rightSection' is in scope, because (a) RebindableSyntax might not be on in the splicing context (b) Even if it is, 'rightSection' might not be in scope (c) At least in the case of Typed Template Haskell we should never get a type error from the splice. We consult the module-wide RebindableSyntax flag here. We could instead record the choice in ExpandedThingRn, but it seems simpler to consult the flag (again).
References 1
- Handling overloaded and rebindable constructs GHC.Rename.Expr
Referenced by 1
- GHC.HsToCore.Quote call site