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


Hello everybody,

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.

Many thanks,
Christian

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
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20140314/9c68e147/attachment.sig>


More information about the Glasgow-haskell-users mailing list