[Haskell-cafe] Haskell syntax inside QuasiQuote
reiner.pope at gmail.com
Mon Oct 20 06:53:51 EDT 2008
I have written a toy fixed-length-vector quasiquoter, so that you can write
which has its type inferred as (Vec (S (S Z))) and you can write
mkVec :: Double -> Vec (S (S (S Z)))
mkVec x = [$vec|1,2,x|]
However, these above examples essentially demonstrate the entire syntax it
supports: number literals, and anti-quoted variables.
I would like to extend my quasiquoter to support Haskell's full expression
syntax, so that we can write, for example,
mkVec2 x = [$vec| if x > 5 then sin x else cos x |]
Is there a simple way to do this, i.e. using existing libraries? What I need
is a Haskell expression parser which outputs values of type
Language.Haskell.TH.Syntax.QExp, but I can't see one available in the TH
libraries, or in the haskell-src(-exts) libraries.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe