This is not possible for the same reason that you cannot write
eval :: ExpQ -> Int eval expr = $expr
because it will require compilation at runtime.
One solution is also to make findTransforms compile time by returning an expression of nested if expressions rather than the value of the specified expression.
findTransforms :: Int -> [ExpQ] -> ExpQ findTransforms _ [] = [| False |] findTransforms e (r:rs) = [| if $re == 1 then True else $(findTransforms e rs) |]
Of course, this means that you will have to splice it when you want to use it.
source share