
28 Jul
2010
28 Jul
'10
7:03 a.m.
2010/7/28 Dušan Kolář
which does not work, of course (Flexible or Undecidable instances won't help). The aim is to have addElem function that works differently according to situation whether a type, which is base of the list/set, is a member of class Eq or Ord. Could you point me or hint me how to get as close as possible to the required solution? Maybe I'm not able to see an obvious way...
Use the good'ol trick: newtype ByEq a = ByEq {unByEq :: a} newtype ByOrd a = ByOrd {unByOrd :: a} instance (Eq a) => SetOL (ByEq a) where addElem = addEq . unByEq instance (Ord a) => SetOL (ByOrd a) where addElem = addOrd . unByOrd Cheers, -- Felipe.