Just by deriving Ord, your datatype can be compared for free, if the components of your datatype are instances of Ord. Each record of your datatype will be compared to similar records of the same datatype, respecting the order: First records are compared first, last records are compared last. Such comparison is lazy: If the first records are greater or lower than others, the comparison is stopped and returns GT or LT. If the first records are equal, the comparison continues to the next records and so on. At the end, the compare
function returns: data Ordering = LT | EQ | GT
Is such default behavior part of the Haskell language or programmed in the instances of Ord? If programmed in the instances of Ord, how can we program similar default behavior when deriving our own typeclasses?