
I put up a patch which removes this restriction (for untyped expressions).
https://gitlab.haskell.org/ghc/ghc/merge_requests/259
On Thu, Jan 24, 2019 at 11:46 AM Matthew Pickering
There is a check in `RnSplice` which errors on the following program with nested brackets.
``` prog = [| [| True |] |]
T.hs:4:11: error: • Template Haskell brackets cannot be nested (without intervening splices) • In the Template Haskell quotation [| True |] In the Template Haskell quotation [| [| True |] |] | 4 | prog = [| [| True |] |] | ^^^^^^^^^^
```
As far as I can see the check was added in 2013 in this commit, https://github.com/ghc/ghc/commit/d0d47ba76f8f0501cf3c4966bc83966ab38cac27#d...
But there is no note, no tests and no comment about why it was added.
I removed the check and added a `BracketE` constructor to the template-haskell AST and the code compiles fine.
I can also construct a program which needs to be spliced twice and this also works fine.
``` func Add = [| (+) |] func Mul = [| (*) |]
f1 "+" = [| Add |] f1 "*" = [| Mul |]
comb s = [| func $(f1 s) |] ``` ``` res = $($(comb "*")) ```
So it seems the restriction is quite arbitrary but I was wondering if I was missing some limitation which meant this check was added. I would not be surprised if something more complicated goes wrong with splicing.
Cheers,
Matt