Are Ord and Enum sometimes incompatible in Haskell?
haskell, typeclass
Solution
`Enum` represents types that can be mapped to/from integers. This doesn't say anything about how those types should be sorted, merely that you can represent them with integers.
`Ord` represents ordered types. This is different than types that can be mapped to integers. For example, you can't map arbitrary-precision floating point values to integers, but you can order them. And while you technically could try and map Floats to integers, nobody in their right mind would do so.
As for `Eq`, `Ord` requires this because it doesn't make sense to have a totally ordered datatype that doesn't support equality. However, `Enum` has no need for `Eq`. Since `Enum` doesn't provide any ordering guarantees, it doesn't provide equality guarantees either.
Problem
Could `Ord` and `Enum` be one typeclass? Why doesn't `Enum` require `Eq`?