3 ms·
Ah, `^` being naturals-only makes more sense in terms of how it could work with no special logic!
by green_on_black 4y ago
Ah, `^` being naturals-only makes more sense in terms of how it could work with no special logic!
- lalaithion 4y agoHaskell has three exponentiation operators: (^) :: (Num a, Integral b) => a -> b -> a (^^) :: (Fractional a, Integral b) => a -> b -> a (**) :: Floating a => a -> a -> a The first one has the un-typed requirement that `b` be nonnegative, and basically allows any value with multiplication (implements the Num typeclass) to be raised to a natural power. The second one allows any value with multiplication and multiplicative inverses (Fractional) to be raised to an integral power. The third one allows any value which supports exponents, trig functions, and logarithms to be raised to a power with the same type. `*` is in fact one of the functions one must implement to implement the Floating typeclass.