
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
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.