Proposal for stand-alone deriving declarations?
John Meacham
john at repetae.net
Mon Oct 30 00:17:15 EST 2006
On Fri, Oct 06, 2006 at 10:39:39AM -0500, Michael Shulman wrote:
> On 10/6/06, John Hughes <rjmh at cs.chalmers.se> wrote:
> >deriving (Eq Foo, Ord Foo)
> >
> >instead of
> >
> >deriving (Eq, Ord) for Foo
>
> So what does
>
> newtype Foo a = Foo a
> newtype Bar b = Bar b
> class C a b
> deriving (C (Foo a) (Bar b))
>
> mean? I could see it meaning any or all of the following:
>
> instance (C (Foo a) b) => (C (Foo a) (Bar b))
> instance (C a (Bar b)) => (C (Foo a) (Bar b))
> instance (C a b) => (C (Foo a) (Bar b))
this is why we should make this explicit when deriving "complex" newtype
instances, so we would write exactly the instance we want to derive:
> deriving (C (Foo a) b) => (C (Foo a) (Bar b))
> deriving (C a (Bar b)) => (C (Foo a) (Bar b))
> deriving (C a b) => (C (Foo a) (Bar b))
respectively.
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-prime
mailing list