Could Ord and Enum be one typeclass? Why doesn’t Enum require Eq?
Could Ord and Enum be one typeclass? Why doesn’t Enum require Eq ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Enumrepresents 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.Ordrepresents 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,Ordrequires this because it doesn’t make sense to have a totally ordered datatype that doesn’t support equality. However,Enumhas no need forEq. SinceEnumdoesn’t provide any ordering guarantees, it doesn’t provide equality guarantees either.