Thanks for the tips, Isaac.  I fixed my Ord decl.  Too bad about the
run-time time & space overhead.  I guess that's not fixable.  Perhaps Simon
will decide to follow Pepe's suggestion of liberal deriving when
UndecidableInstances enabled.

Cheers, - Conal

On 8/21/07, Isaac Dupree <[EMAIL PROTECTED]> wrote:
>
> Conal Elliott wrote:
> > Thanks, Simon.  The manual deriving is easier than I expected, by
> > boilerplate delegation of constraints & methods, as below.  You may want
> to
> > give such an example when you document the change.   Cheers,  - Conal
> >
> > -- | Pairing of type constructors
> > newtype (f :*: g) a = Prod { unProd :: (f a, g a) }
> >   -- deriving (Show, Eq, Ord)
> >
> > -- Deriving no longer works on types like :*:.  So:
> > instance (Show (f a, g a)) => Show ((f :*: g) a) where
> >   show (Prod p) = "Prod " ++ show p
> > instance (Eq (f a, g a)) => Eq ((f :*: g) a) where
> >   Prod p == Prod q = p == q
> > instance (Ord (f a, g a)) => Ord ((f :*: g) a) where
> >   Prod p < Prod q = p < q
>
> Hmm, the Eq and Ord instances won't have the efficiency of newtype
> deriving of sharing the Eq and Ord dictionaries with the (,) type to
> which the operations are delegated.  In fact I think that Ord definition
> is not correct because it didn't happen to choose one of (<=) and
> (compare), Ord's minimal definition (and even if it did, it's still more
> slightly-runtime-inefficient not to implement all those methods,
> depending on (f a) and (g a)'s Ord instances)
>
> Isaac
>
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to