2010/7/28 Dušan Kolář <ko...@fit.vutbr.cz>:
> 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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to