Haskell has the Integral typeclass which includes Integer, Int, Int32, Int64, Natural, etc.
Is there a similar typeclass in Purescript?
Join Stack Overflow to learn, share knowledge, and build your career.
Haskell has the Integral typeclass which includes Integer, Int, Int32, Int64, Natural, etc.
Is there a similar typeclass in Purescript?
We don't have any integer-specific classes in PureScript, but there is a hierarchy of numeric classes:
Each class adds laws, so although the CommutativeRing and Field classes have no operations they are not redundant.
Any type that is a EuclideanRing also satisfies the laws for integral domains, which generalise integers, so I think that should suit your needs.
Fields have non-zero multiplicative inverses: mod a b = 0 for all a and b, so using that constraint would rule out the possibility of integer division, etc. if that's what you're looking for, so you definitely don't want to that far down the hierarchy.