[Template-haskell] Re: template haskell (reify bug and existentials)

Keean Schupke k.schupke at imperial.ac.uk
Tue Nov 2 07:18:51 EST 2004


Ian, What are the chances of getting fundeps added to class declarations?
I only need to generate them so support in the syntax and pretty-printer
is all that is required... Here are the changes I have made to my local copy
to get it working. I suppose this breaks existing code! Perhaps you would
rather have a new constructor for classes with fundeps?

    Keean

in Syntax.hs:
    ...
    type Fundep = ([Name],[Name]) -- add to export list
    ...
    | ClassD Cxt Name [Name] [Dec] [Fundep]

in Ppr.hs:
    ...
    ppr (ClassD ctxt c xs ds fd) = text "class" <+> pprCxt ctxt
                            <+> ppr c <+> hsep (map ppr xs) <+> pprFd fd
                             $$ where_clause ds
    ...
    pprFd :: [Fundep] -> Doc
    pprFd fds@(_:_) = char '|' <+> hsep (punctuate comma $ map
       (\(l,r) -> (hsep $ map ppr l) <+> text "->" <+> (hsep $ map ppr 
r)) fds)
    pprFd _ = empty

in Lib.hs
    ...
    classD :: CxtQ -> Name -> [Name] -> [DecQ] -> [Fundep] -> DecQ
    classD ctxt cls tvs decs fd =
      do
        decs1 <- sequence decs
        ctxt1 <- ctxt
        return $ ClassD ctxt1 cls tvs decs1 fd

Ian Lynagh wrote:

>On Sat, Oct 30, 2004 at 03:01:02PM +0100, Keean Schupke wrote:
>  
>
>>Re: my two earlier postings:
>>
>>1) existentials in data declarations. I have a project which needs this,
>>   Simon PJ thought it was fairly easy to put in and suggested that Ian
>>   Lynagh might implement it. Do I need to persuade people further?
>>    
>>
>
>No - I've just got back from a conference with poor 'net access, so have
>only just read your original message. I should get to this RSN.
>
>
>Thanks
>Ian
>
>  
>



More information about the template-haskell mailing list