I would like to list all fixity declarations in Quasiquote monad so I am able to pass all the infix operators from Haskell grammar to my Quasiquote grammar.
Is there any method in template-haskell
which allows me to do so please? I can't find any.
Thanks.
After further research I have found the related issue in GHC Gitlab.
The problem can't have any solution because the compilation logic can't allow that. For example, there might be two templates, both of which make a new fixity declaration and therefore if both of them are trying to list them all, they might end in an endless loop.
If the only reason, why do I want to get all fixity declarations is parsing infix operators to be later used by Haskell, the usage of UInfixE Exp Exp Exp
is recommended.
The arbitrary tree created using the UInfixE
is later processed by Haskell compiler to the correct "InfixE"
tree, so the expression is correctly processed with all the fixity declarations.
Syntax careless and type ignoring example:
UInfixE 1 * (UnfixE 2 + 3)
passed by a template gets transformed in later phase of compilation, when all fixity declarations are known, to InfixE (InfixE 1 * 2) + 3