[Template-haskell] using template haskell to implement pads for
haskell?
Ian Lynagh
igloo at earth.li
Sun Jun 29 16:08:41 EDT 2008
Hi David,
On Sun, Jun 29, 2008 at 03:25:47PM -0400, David Walker wrote:
>
> {|
> pdata Line =
> Comment /#.*/
> | Name {first::Pstr /;/,
> last ::Pstr /\n/}
>
> ptype Friends = (x::Pint, |{ x > 0 }|, /\n/, PlistFW x)
> |}
You can't create new syntax with TH; it's just Haskell (plus the TH
syntactic extensions themselves, i.e. $( e ), and a few variants of
[| e |]).
You'd have to encode the info into Haskell syntax somehow, e.g.
something like
$(
pdata "Line" [C "Comment" [], C "Name" [ ("first", ["Pstr", "/;"]),
...
)
or parse them from strings (which isn't nice either, as Haskell doesn't
have nice multi-line strings).
Thanks
Ian
More information about the template-haskell
mailing list