Try deleting the line beginning instance Ord Postcode and you will see it blow up. I believe this is because:
applyRate :: Ord t => RateTable t -> t -> Money -> Money
GHC infers that the type of applyRate's second param must be Ord, because the function's implementation in Bands compares it using >. Even though that code path isn't taken for Postcode comparison.
Try deleting the line beginning
instance Ord Postcode
and you will see it blow up. I believe this is because:GHC infers that the type of
applyRate
's second param must beOrd
, because the function's implementation inBands
compares it using>
. Even though that code path isn't taken for Postcode comparison.Is there a better way?