I just couldn't find out how can I implement a special ord for my datatypes in haskell. I read on the forum, that it should look somewhat like this:
import Data.Set
data Cord = Cord { x :: Int
, y :: Int} deriving (Eq,Ord)
instance Eq Cord where
(Cord a b) == (Cord a b) = (a==c and b==d)
instance Ord Cord where
compare (Cord a b) (Cord c d) = if a==c then compare (b d) else compare(a c)
I want to create a simple type with 2 integers, and one is larger then the other if his first number is larger then the other ones first number, or the second ones if the firsts are equal. I know that this comparison can be done by creating lists of 2 integers, however i wan't to some lot more complex data types and can't find anywhere a guide how to define an ord with if-s and recursions.
Thank you for your anwser!