<div dir="ltr">Hi,<br><br>I have written a toy fixed-length-vector quasiquoter, so that you can write<br><br>[$vec|1,2|]<br><br>which has its type inferred as (Vec (S (S Z))) and you can write<br><br>mkVec :: Double -&gt; Vec (S (S (S Z)))<br>
mkVec x = [$vec|1,2,x|]<br><br>However, these above examples essentially demonstrate the entire syntax it supports: number literals, and anti-quoted variables. <br><br>I would like to extend my quasiquoter to support Haskell&#39;s full expression syntax, so that we can write, for example,<br>
<br>mkVec2 x = [$vec| if x &gt; 5 then sin x else cos x |]<br><br>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&#39;t see one available in the TH libraries, or in the haskell-src(-exts) libraries.<br>
<br>Thoughts?<br><br>Cheers,<br><br>Reiner<br></div>