NumericPrelude-0.0: An experimental alternative hierarchy of numeric type classesContentsIndex
Algebra.Ring
Contents
Class
Complex functions
Properties
Synopsis
class C a => C a where
(*) :: a -> a -> a
one :: a
fromInteger :: Integer -> a
(^) :: a -> Integer -> a
(*) :: C a => a -> a -> a
one :: C a => a
fromInteger :: C a => Integer -> a
(^) :: C a => a -> Integer -> a
sqr :: C a => a -> a
product :: C a => [a] -> a
product1 :: C a => [a] -> a
scalarProduct :: C a => [a] -> [a] -> a
propAssociative :: (Eq a, C a) => a -> a -> a -> Bool
propLeftDistributive :: (Eq a, C a) => a -> a -> a -> Bool
propRightDistributive :: (Eq a, C a) => a -> a -> a -> Bool
propLeftIdentity :: (Eq a, C a) => a -> Bool
propRightIdentity :: (Eq a, C a) => a -> Bool
propPowerCascade :: (Eq a, C a) => a -> Integer -> Integer -> Property
propPowerProduct :: (Eq a, C a) => a -> Integer -> Integer -> Property
propPowerDistributive :: (Eq a, C a) => Integer -> a -> a -> Property
propCommutative :: (Eq a, C a) => a -> a -> Bool
Class
class C a => C a where

Ring encapsulates the mathematical structure of a (not necessarily commutative) ring, with the laws

  a * (b * c) === (a * b) * c
      one * a === a
      a * one === a
  a * (b + c) === a * b + a * c

Typical examples include integers, polynomials, matrices, and quaternions.

Minimal definition: *, (one or fromInteger)

Methods
(*) :: a -> a -> a
one :: a
fromInteger :: Integer -> a
(^) :: a -> Integer -> a

The exponent has fixed type Integer in order to avoid an arbitrarily limitted range of exponents, but to reduce the need for the compiler to guess the type (default type). In practice the exponent is most oftenly fixed, and is most oftenly 2. Fixed exponents can be optimized away and thus the expensive computation of Integers doesn't matter. The previous solution used a ToInteger constrained type and the exponent was converted to Integer before computation. So the current solution is not less efficient.

A variant of ^ with more flexibility is provided by ringPower.

show/hide Instances
C Double
C Float
C Int
C Integer
C T
C T
Integral a => C (Ratio a)
C a => C (T a)
C a => C (T a)
(C a, C a) => C (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
(C a, C a) => C (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
(Eq a, C a) => C (T a)
C a => C (T a)
(Eq a, C a) => C (T a)
(Ord a, C a, C b) => C (T a b)
C v => C (T a v)
C v => C (T a v)
(Ord i, C a) => C (T i a)
(*) :: C a => a -> a -> a
one :: C a => a
fromInteger :: C a => Integer -> a
(^) :: C a => a -> Integer -> a

The exponent has fixed type Integer in order to avoid an arbitrarily limitted range of exponents, but to reduce the need for the compiler to guess the type (default type). In practice the exponent is most oftenly fixed, and is most oftenly 2. Fixed exponents can be optimized away and thus the expensive computation of Integers doesn't matter. The previous solution used a ToInteger constrained type and the exponent was converted to Integer before computation. So the current solution is not less efficient.

A variant of ^ with more flexibility is provided by ringPower.

sqr :: C a => a -> a
Complex functions
product :: C a => [a] -> a
product1 :: C a => [a] -> a
scalarProduct :: C a => [a] -> [a] -> a
Properties
propAssociative :: (Eq a, C a) => a -> a -> a -> Bool
propLeftDistributive :: (Eq a, C a) => a -> a -> a -> Bool
propRightDistributive :: (Eq a, C a) => a -> a -> a -> Bool
propLeftIdentity :: (Eq a, C a) => a -> Bool
propRightIdentity :: (Eq a, C a) => a -> Bool
propPowerCascade :: (Eq a, C a) => a -> Integer -> Integer -> Property
propPowerProduct :: (Eq a, C a) => a -> Integer -> Integer -> Property
propPowerDistributive :: (Eq a, C a) => Integer -> a -> a -> Property
propCommutative :: (Eq a, C a) => a -> a -> Bool
Commutativity need not be satisfied by all instances of C.
Produced by Haddock version 0.7