[Template-haskell] Instance declarations

Derek Elkins ddarius86@hotmail.com
Wed, 19 Feb 2003 17:52:04 -0500


Sorry about that.  It looks like it was my fault.  I made a list of 
functions rather than a list of clauses.






>From: "Simon Peyton-Jones" <simonpj@microsoft.com>
>To: "Derek Elkins" <ddarius86@hotmail.com>,<template-haskell@haskell.org>
>Subject: RE: [Template-haskell] Instance declarations
>Date: Wed, 19 Feb 2003 15:21:54 -0000
>
>Can you give the actual source code for the offending program, please?
>
>Simon
>
>| -----Original Message-----
>| From: Derek Elkins [mailto:ddarius86@hotmail.com]
>| Sent: 13 February 2003 20:29
>| To: template-haskell@haskell.org
>| Subject: [Template-haskell] Instance declarations
>|
>| My first email seems to have gotten lost, if it meanders it's way
>here, then
>| sorry for the repeat.
>|
>| Anyways, generating a set of pattern matching functions in an instance
>| declaration (maybe in general, though I haven't tested it) causes a
>| "conflicting definitions error".  Rewriting as a case expression is
>one
>| work-around.
>|
>| E.g.
>|
>| instance (NFData a) => NFData (Tree a) where
>|     rnf (Leaf a) = rnf a
>|     rnf (Branch a b) = rnf a `seq` rnf b
>|
>| doesn't work, but rewriting as
>|
>| instance (NFData a) => NFData (Tree a) where
>|     rnf x = case x of
>|               (Leaf a) -> rnf a
>|               (Branch a b) -> rnf a `seq` rnf b
>|
>| does.
>|
>| I suspect that it may have to do with the generated code being
>considered at
>| a lower level (i.e. the transformation of the above into the below is
>| already considered done).  It may just be I'm creating the functions
>| incorrectly, so if you can't get the error to happen I can provide the
>code
>| I'm using.
>|
>| Separately: I've written a variety of fold algebras over data
>declarations.
>| I'm not sure how useful they'll be, but if you're interested email me,
>and
>| I'll email the source.  I haven't tested them, but it's pretty
>mechanical
>| code so I don't suspect any major problems and any should be
>relatively
>| straightforward to fix.  See `Dealing with Large Bananas` for the
>concept
>| (and for documentation, as it has no documentation yet).
>|
>| _________________________________________________________________
>| STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
>| http://join.msn.com/?page=features/junkmail
>|
>| _______________________________________________
>| template-haskell mailing list
>| template-haskell@haskell.org
>| http://www.haskell.org/mailman/listinfo/template-haskell
>_______________________________________________
>template-haskell mailing list
>template-haskell@haskell.org
>http://www.haskell.org/mailman/listinfo/template-haskell


_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail