Re: implementing a class using superclasses?
Mark McConnell via Haskell-Cafe <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <[email protected]> |
Thank you to everyone who replied. The thing I was misunderstanding was, to quote Jade, "This attempts to define `Ord a` in general, for *every* type `a` at once. The `Lex2 a` constraint is only checked *after* the compiler has decided this is the instance to use."
I appreciate seeing how a Proxy constructor, or DerivingVia, would solve the problem. However, I decided just to document carefully what I was doing.
On Wednesday, March 26, 2025 at 06:14:00 PM EDT, Jade Hagborg <[email protected]> wrote:
On Wed, 2025-03-26 at 18:08 -0400, Jade Hagborg via Haskell-Cafe wrote:
> instance (Primary a, Secondary a) => Ord (Lex2 a) where
> compare (MkLex2 x) (MkLex2 y) = comp1 x y <> comp2 x y
My bad (copy-paste error), should be
instance (Primary a, Secondary a) => Ord (UsePrimaryAndSecondary a) where
compare (MkUsePrimaryAndSecondary x)
(MkUsePrimaryAndSecondary y) = comp1 x y <> comp2 x y
Sorry if that caused confusion.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.