Re: using template haskell to implement pads for haskell?

Ian Lynagh <[email protected]> Sun, 29 Jun 2008 21:08:41 +0100
Newsgroups gmane.comp.lang.haskell.template
Message-ID <[email protected]>
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