I think writing code in this way is redundant. Regardless of what the type constructors are, the return values are all the same. Is there a way to write the return values once for all?
data End = Leftend (Int,Int) | Rightend (Int, Int)
deriving (Eq, Ord, Show)
cmp:: End->End->Ordering
cmp (Leftend (l, h1)) (Rightend (r,h2))
| l < r = LT
| l == r = EQ
| l > r = GT
cmp (Leftend (l, h1)) (Leftend (r,h2))
| l < r = LT
| l == r = EQ
| l > r = GT
cmp (Rightend (l, h1)) (Rightend (r,h2))
| l < r = LT
| l == r = EQ
| l > r = GT
cmp (Rightend (l, h1)) (Leftend (r,h2))
| l < r = LT
| l == r = EQ
| l > r = GT
data Side = Left | Right; data End = End { side :: Side, width :: Int, height :: Int }or similar. Thencmp = comparing width, and is probably not even worth giving a name to.| l < r = LT | l == r = EQ | l > r = GTthat keeps appearing is justcompare l r