Neg operator "~" has arity 1, fixity 0, priority 1.As negative numbers don't really make much sense as the arity and fixity of an operator, I've just spent a while knocking up a Haskell implementation of the natural numbers.
While I dislike programming in Java and other "OO" languages, they do make it
My new type Natural (just a wrapper around Integer) is an instance of eight separate type classes:
- Eq (they can be compared for equality)
- Ord (values can be ordered with respect to each other)
- Show (values can be converted to strings)
- Read (values can be parsed out of strings)
- Bounded (the range of values is bounded), though Natural shouldn't have an upper bound
- Enum (values can be enumerated)
- Num (values are numbers)
- Real (values are real numbers)
- Integral (values are integral numbers)
- Random (values can be randomly generated); and
- Ix (values can used as array indices)
No comments:
Post a Comment