License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Foundation.Numerical
Description
Compared to the Haskell hierarchy of number classes this provide a more flexible approach that is closer to the mathematical foundation (group, field, etc)
This try to only provide one feature per class, at the expense of the number of classes.
Synopsis
- class (Integral a, Eq a, Ord a) => IsIntegral a where
- class IsIntegral a => IsNatural a where
- class Signed a where
- class Additive a where
- class Subtractive a where
- type Difference a
- (-) :: a -> a -> Difference a
- class Multiplicative a where
- class (Additive a, Multiplicative a) => IDivisible a where
- class Multiplicative a => Divisible a where
- (/) :: a -> a -> a
- data Sign
- recip :: Divisible a => a -> a
- class IntegralRounding a where
- roundUp :: Integral n => a -> n
- roundDown :: Integral n => a -> n
- roundTruncate :: Integral n => a -> n
- roundNearest :: Integral n => a -> n
- class FloatingPoint a where
- floatRadix :: Proxy a -> Integer
- floatDigits :: Proxy a -> Int
- floatRange :: Proxy a -> (Int, Int)
- floatDecode :: a -> (Integer, Int)
- floatEncode :: Integer -> Int -> a
Documentation
class (Integral a, Eq a, Ord a) => IsIntegral a where #
Instances
class IsIntegral a => IsNatural a where #
Instances
types that have sign and can be made absolute
Instances
class Subtractive a where #
Associated Types
type Difference a #
Methods
(-) :: a -> a -> Difference a #
Instances
Subtractive Char | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Char # | |
Subtractive Double | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Double # | |
Subtractive Float | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Float # | |
Subtractive Int | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Int # | |
Subtractive Int8 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Int8 # | |
Subtractive Int16 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Int16 # | |
Subtractive Int32 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Int32 # | |
Subtractive Int64 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Int64 # | |
Subtractive Integer | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Integer # | |
Subtractive Natural | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Natural # | |
Subtractive Word | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word # | |
Subtractive Word8 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word8 # | |
Subtractive Word16 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word16 # | |
Subtractive Word32 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word32 # | |
Subtractive Word64 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word64 # | |
Subtractive CInt | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CInt # Methods (-) :: CInt -> CInt -> Difference CInt # | |
Subtractive CSize | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CSize # Methods (-) :: CSize -> CSize -> Difference CSize # | |
Subtractive CChar | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CChar # Methods (-) :: CChar -> CChar -> Difference CChar # | |
Subtractive CUChar | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUChar # Methods (-) :: CUChar -> CUChar -> Difference CUChar # | |
Subtractive Word128 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word128 # | |
Subtractive Word256 | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference Word256 # | |
Subtractive CDouble | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CDouble # Methods (-) :: CDouble -> CDouble -> Difference CDouble # | |
Subtractive CFloat | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CFloat # Methods (-) :: CFloat -> CFloat -> Difference CFloat # | |
Subtractive CIntMax | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CIntMax # Methods (-) :: CIntMax -> CIntMax -> Difference CIntMax # | |
Subtractive CLLong | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CLLong # Methods (-) :: CLLong -> CLLong -> Difference CLLong # | |
Subtractive CLong | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CLong # Methods (-) :: CLong -> CLong -> Difference CLong # | |
Subtractive CPtrdiff | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CPtrdiff # Methods (-) :: CPtrdiff -> CPtrdiff -> Difference CPtrdiff # | |
Subtractive CSChar | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CSChar # Methods (-) :: CSChar -> CSChar -> Difference CSChar # | |
Subtractive CShort | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CShort # Methods (-) :: CShort -> CShort -> Difference CShort # | |
Subtractive CWchar | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CWchar # Methods (-) :: CWchar -> CWchar -> Difference CWchar # | |
Subtractive CBool | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CBool # Methods (-) :: CBool -> CBool -> Difference CBool # | |
Subtractive CClock | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CClock # Methods (-) :: CClock -> CClock -> Difference CClock # | |
Subtractive CIntPtr | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CIntPtr # Methods (-) :: CIntPtr -> CIntPtr -> Difference CIntPtr # | |
Subtractive COff | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference COff # Methods (-) :: COff -> COff -> Difference COff # | |
Subtractive CSUSeconds | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CSUSeconds # Methods (-) :: CSUSeconds -> CSUSeconds -> Difference CSUSeconds # | |
Subtractive CSigAtomic | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CSigAtomic # Methods (-) :: CSigAtomic -> CSigAtomic -> Difference CSigAtomic # | |
Subtractive CTime | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CTime # Methods (-) :: CTime -> CTime -> Difference CTime # | |
Subtractive CUInt | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUInt # Methods (-) :: CUInt -> CUInt -> Difference CUInt # | |
Subtractive CUIntMax | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUIntMax # Methods (-) :: CUIntMax -> CUIntMax -> Difference CUIntMax # | |
Subtractive CUIntPtr | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUIntPtr # Methods (-) :: CUIntPtr -> CUIntPtr -> Difference CUIntPtr # | |
Subtractive CULLong | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CULLong # Methods (-) :: CULLong -> CULLong -> Difference CULLong # | |
Subtractive CULong | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CULong # Methods (-) :: CULong -> CULong -> Difference CULong # | |
Subtractive CUSeconds | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUSeconds # Methods (-) :: CUSeconds -> CUSeconds -> Difference CUSeconds # | |
Subtractive CUShort | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference CUShort # Methods (-) :: CUShort -> CUShort -> Difference CUShort # | |
Subtractive (Offset ty) | |
Defined in Basement.Types.OffsetSize Associated Types type Difference (Offset ty) # | |
Subtractive (CountOf ty) | |
Defined in Basement.Types.OffsetSize Associated Types type Difference (CountOf ty) # | |
SizeValid n => Subtractive (Bits n) | |
Defined in Basement.Bits Associated Types type Difference (Bits n) # Methods (-) :: Bits n -> Bits n -> Difference (Bits n) # | |
KnownNat n => Subtractive (Zn n) | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference (Zn n) # Methods (-) :: Zn n -> Zn n -> Difference (Zn n) # | |
(KnownNat n, NatWithinBound Word64 n) => Subtractive (Zn64 n) | |
Defined in Basement.Numerical.Subtractive Associated Types type Difference (Zn64 n) # Methods (-) :: Zn64 n -> Zn64 n -> Difference (Zn64 n) # |
class Multiplicative a where #
Methods
(^) :: (IsNatural n, Enum n, IDivisible n) => a -> n -> a #
Instances
class (Additive a, Multiplicative a) => IDivisible a where #
Instances
IDivisible Int | |
IDivisible Int8 | |
IDivisible Int16 | |
IDivisible Int32 | |
IDivisible Int64 | |
IDivisible Integer | |
IDivisible Natural | |
IDivisible Word | |
IDivisible Word8 | |
IDivisible Word16 | |
IDivisible Word32 | |
IDivisible Word64 | |
IDivisible CInt | |
IDivisible CSize | |
IDivisible CChar | |
IDivisible CUChar | |
IDivisible Word128 | |
IDivisible Word256 | |
IDivisible CIntMax | |
IDivisible CLLong | |
IDivisible CLong | |
IDivisible CPtrdiff | |
IDivisible CSChar | |
IDivisible CShort | |
IDivisible CWchar | |
IDivisible CIntPtr | |
IDivisible CSigAtomic | |
IDivisible CUInt | |
IDivisible CUIntMax | |
IDivisible CUIntPtr | |
IDivisible CULLong | |
IDivisible CULong | |
IDivisible CUShort | |
SizeValid n => IDivisible (Bits n) | |
class Multiplicative a => Divisible a where #
Instances
Divisible Double | |
Divisible Float | |
Divisible Rational | |
Divisible CDouble | |
Defined in Basement.Numerical.Multiplicative | |
Divisible CFloat | |
Defined in Basement.Numerical.Multiplicative |
Sign of a signed number
Constructors
SignNegative | |
SignZero | |
SignPositive |
class IntegralRounding a where Source #
Methods
roundUp :: Integral n => a -> n Source #
Round up, to the next integral.
Also known as ceiling
roundDown :: Integral n => a -> n Source #
Round down, to the previous integral
Also known as floor
roundTruncate :: Integral n => a -> n Source #
Truncate to the closest integral to the fractional number closer to 0.
This is equivalent to roundUp for negative Number and roundDown for positive Number
roundNearest :: Integral n => a -> n Source #
Round to the nearest integral
roundNearest 3.6
4 > roundNearest 3.4 3
class FloatingPoint a where Source #
IEEE754 Floating Point
Methods
floatRadix :: Proxy a -> Integer Source #
floatDigits :: Proxy a -> Int Source #
floatRange :: Proxy a -> (Int, Int) Source #
floatDecode :: a -> (Integer, Int) Source #
floatEncode :: Integer -> Int -> a Source #