[Haskell-cafe] Newbie Q: Deriving MyOrd from Eq problem
Dmitri O.Kondratiev
dokondr at gmail.com
Tue Jul 25 12:15:41 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)
I get these errors:
ClassTest.hs:28:21:
Could not deduce (Ord a) from the context (MyOrd a)
arising from use of `<' at C:/wks/haskell-wks/ClassTest.hs:28:21
Probable fix: add (Ord a) to the class or instance method `%<='
In the first argument of `(||)', namely `x < y'
In the definition of `%<=': %<= x y = ((x < y) || (x == y))
In the definition for method `%<='
ClassTest.hs:29:20:
Could not deduce (Ord a) from the context (MyOrd a)
arising from use of `<' at C:/wks/haskell-wks/ClassTest.hs:29:20
Probable fix: add (Ord a) to the class or instance method `%>'
In the definition of `%>': %> x y = y < x
In the definition for method `%>'
ClassTest.hs:30:21:
Could not deduce (Ord a) from the context (MyOrd a)
arising from use of `<' at C:/wks/haskell-wks/ClassTest.hs:30:21
Probable fix: add (Ord a) to the class or instance method `%>='
In the first argument of `(||)', namely `y < x'
In the definition of `%>=': %>= x y = ((y < x) || (x == y))
In the definition for method `%>='
Failed, modules loaded: none.
Q: What's wrong? Why 'Ord' gets into play here?
Thanks,
Dima
More information about the Haskell-Cafe
mailing list