splicing varPs in quasi-quote brackets
Christian Höner zu Siederdissen
choener at tbi.univie.ac.at
Fri Mar 14 21:46:31 UTC 2014
I wrote me this nice function 'buildRns' which splices in $(varP w) nice
and recursively. Unfortunately, this only seems to work in the 7.8
branch, not in 7.6.3. Is this indeed new, or am I missing something
obvious? The message is:
ADP/Fusion/TH.hs:106:86: Parse error in pattern: $(varP w)
The code works wonderfully in 7.8. It not only compiles, but also
produces working code in applications. I have no problem waiting until
7.8 is stable, but being backwards compatible to 7.6 would be nice.
buildRns f xs  = appE ([| return . SM.singleton |]) (foldl (\g z -> appE g (varE z)) (return f) xs)
buildRns f xs (VarP v : ys) = buildRns f (xs++[v]) ys
buildRns f xs (TupP [_,VarP v] : ys) = do w <- newName "w"
[| $(varE v) >>= return . SM.concatMapM (\ $(varP w) -> $(buildRns f (xs++[w]) ys)) |]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
More information about the Glasgow-haskell-users