40 | | === The Num class === |
41 | | Issues: |
42 | | * `Eq` and `Show` don't make sense for functions under lifting. |
43 | | * `(*)` doesn't make sense for vectors. |
44 | | * `abs` and `signum` don't make sense for `Complex Integer` (Gaussian integers), vectors, matrices, etc. |
45 | | In general, `abs` and `signum` make it hard to lift `Num` through type constructors. |
46 | | |
47 | | Proposals: |
48 | | * A group-like class with `zero`, `(+)` and `negate`/`(-)`. |
49 | | * (Could be further split with a monoid sub-class.) |
50 | | * A ring-like subclass adding `(*)` and `one`/`fromInteger`, with the existing `Num` class as a further subclass. |
51 | | * (Could be further split with a semiring subclass, e.g. for [wiki:Natural natural numbers].) |
52 | | Note that the `Float` and `Double` instances will not satisfy the usual axioms for these structures. |
53 | | |
54 | | === The Real class === |
55 | | Issues: |
56 | | * The class assumes a mapping to `Rational`, but this cannot be defined for structures intermediate between the rationals and reals even though the operations of subclasses make sense for them, e.g. surds, computable reals. |
57 | | |
58 | | === The Fractional class === |
59 | | Issues: |
60 | | * `(/)`, `recip` and `fromRational` can be lifted to functions, but many of the pre-requisites can't be defined for these. |
61 | | |
62 | | Proposals: |
63 | | * Add a division ring-like superclass adding these operations to the ring-like class. |
64 | | (A division ring has the same operations as a field, but does not assume commutative multiplication, allowing structures such as quaternions.) |
65 | | * Add default |
66 | | {{{ |
67 | | fromRational x = fromInteger (numerator x) / fromInteger (denominator x) |
68 | | }}} |
69 | | This is independent of all the other proposals. |
70 | | |
71 | | === The Integral class === |
72 | | Issues: |
73 | | * `div` and `mod` also sense for rationals, polynomials and Gaussian integers, but `Enum` and `toInteger` do not. |
74 | | * `Ord`, `Num(abs, signum)` and `toRational` don't make sense for polynomials and Gaussian integers. |
75 | | * `quot` and `rem` assume an ordering. |
| 34 | See NumericClasses. |