[Haskell-cafe] Newbie Q: Deriving MyOrd from Eq problem
Jared Updike
jupdike at gmail.com
Tue Jul 25 12:34:10 EDT 2006
> I am trying to derive MyOrd class from Eq (Prelude):
>
> class Eq a => MyOrd a where
> (%<=), (%>), (%>=) :: a -> a -> Bool
> x %<= y = (x < y || x == y)
> x %> y = y < x
> x %>= y = (y < x || x == y)
>
> Q: What's wrong? Why 'Ord' gets into play here?
You are using < which is a function on types that instance the class
Ord, so the compiler is telling you to add (Ord a) to the same place
you have (Eq a) or don't use < or > or any function in the class Ord.
You can the prelude and thus the Ord class and make your own < and >
functions but you can't make them refer to the "real" < and >
functions without Ord because that is where they live.
Jared.
--
http://www.updike.org/~jared/
reverse ")-:"
More information about the Haskell-Cafe
mailing list