Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Numeric.MixedTypes.Round
Description
Synopsis
- class CanDivIMod t1 t2 where
- type CanDivIModIntegerSameType t = (CanDivIMod t t, DivIType t t ~ Integer, ModType t t ~ t)
- type CanDivIModIntegerSameTypeCN t = (CanDivIMod t t, DivIType t t ~ CN Integer, ModType t t ~ t)
- class CanRound t where
- class HasIntegerBounds t where
- integerBounds :: t -> (Integer, Integer)
- specCanDivIMod :: (Arbitrary t, CanTestFinite t, CanDivIMod t t, HasOrderAsymmetric t Integer, HasOrderAsymmetric (ModType t t) t, HasOrderAsymmetric Integer (ModType t t), HasEqAsymmetric t (AddType (MulType (DivIType t t) t) (ModType t t)), CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType (ModType t t) t), CanTestCertainly (OrderCompareType Integer (ModType t t)), CanTestCertainly (EqCompareType t (AddType (MulType (DivIType t t) t) (ModType t t))), Show t, Show (ModType t t), Show (AddType (MulType (DivIType t t) t) (ModType t t)), CanAddAsymmetric (MulType (DivIType t t) t) (ModType t t), CanMulAsymmetric (DivIType t t) t) => T t -> Spec
- specCanRound :: (Arbitrary t, CanTestFinite t, Show t, Show (RoundType t), CanRound t, CanSub (RoundType t) (RoundType t), HasOrderAsymmetric t (RoundType t), HasOrderAsymmetric (SubType (RoundType t) (RoundType t)) Integer, HasOrderAsymmetric (RoundType t) t, HasOrderAsymmetric (RoundType t) (RoundType t), HasOrderAsymmetric Integer (SubType (RoundType t) (RoundType t)), HasEqAsymmetric (RoundType t) (RoundType t), CanTestCertainly (OrderCompareType t (RoundType t)), CanTestCertainly (OrderCompareType (SubType (RoundType t) (RoundType t)) Integer), CanTestCertainly (OrderCompareType (RoundType t) t), CanTestCertainly (OrderCompareType (RoundType t) (RoundType t)), CanTestCertainly (OrderCompareType Integer (SubType (RoundType t) (RoundType t))), CanTestCertainly (EqCompareType (RoundType t) (RoundType t)), ConvertibleExactlyWithSample Integer t) => T t -> Spec
- specHasIntegerBounds :: (Arbitrary t, Show t, CanTestFinite t, HasIntegerBounds t, HasOrderAsymmetric t Integer, HasOrderAsymmetric Integer t, CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType Integer t)) => T t -> Spec
Rounded division + modulus
class CanDivIMod t1 t2 where Source #
Minimal complete definition
Methods
divIMod :: t1 -> t2 -> (DivIType t1 t2, ModType t1 t2) Source #
Instances
type CanDivIModIntegerSameType t = (CanDivIMod t t, DivIType t t ~ Integer, ModType t t ~ t) Source #
type CanDivIModIntegerSameTypeCN t = (CanDivIMod t t, DivIType t t ~ CN Integer, ModType t t ~ t) Source #
Rounding
class CanRound t where Source #
A replacement for Prelude's RealFrac
operations, such as round in
which the result type is fixed to Integer.
If RealFrac t
and CanTestPosNeg t
,
then one can use the default implementation to mirror Prelude's round
, etc.
In other cases, it is sufficient to define properFraction
.
Minimal complete definition
Nothing
Methods
properFraction :: t -> (RoundType t, t) Source #
truncate :: t -> RoundType t Source #
round :: t -> RoundType t Source #
Instances
CanRound Rational Source # | |||||
Defined in Numeric.MixedTypes.Round Associated Types
| |||||
CanRound Double Source # | |||||
Defined in Numeric.MixedTypes.Round Associated Types
|
class HasIntegerBounds t where Source #
Minimal complete definition
Nothing
Methods
integerBounds :: t -> (Integer, Integer) Source #
Instances
HasIntegerBounds Rational Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Integer Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Double Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Int Source # | |
Defined in Numeric.MixedTypes.Round |
Tests
specCanDivIMod :: (Arbitrary t, CanTestFinite t, CanDivIMod t t, HasOrderAsymmetric t Integer, HasOrderAsymmetric (ModType t t) t, HasOrderAsymmetric Integer (ModType t t), HasEqAsymmetric t (AddType (MulType (DivIType t t) t) (ModType t t)), CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType (ModType t t) t), CanTestCertainly (OrderCompareType Integer (ModType t t)), CanTestCertainly (EqCompareType t (AddType (MulType (DivIType t t) t) (ModType t t))), Show t, Show (ModType t t), Show (AddType (MulType (DivIType t t) t) (ModType t t)), CanAddAsymmetric (MulType (DivIType t t) t) (ModType t t), CanMulAsymmetric (DivIType t t) t) => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.
specCanRound :: (Arbitrary t, CanTestFinite t, Show t, Show (RoundType t), CanRound t, CanSub (RoundType t) (RoundType t), HasOrderAsymmetric t (RoundType t), HasOrderAsymmetric (SubType (RoundType t) (RoundType t)) Integer, HasOrderAsymmetric (RoundType t) t, HasOrderAsymmetric (RoundType t) (RoundType t), HasOrderAsymmetric Integer (SubType (RoundType t) (RoundType t)), HasEqAsymmetric (RoundType t) (RoundType t), CanTestCertainly (OrderCompareType t (RoundType t)), CanTestCertainly (OrderCompareType (SubType (RoundType t) (RoundType t)) Integer), CanTestCertainly (OrderCompareType (RoundType t) t), CanTestCertainly (OrderCompareType (RoundType t) (RoundType t)), CanTestCertainly (OrderCompareType Integer (SubType (RoundType t) (RoundType t))), CanTestCertainly (EqCompareType (RoundType t) (RoundType t)), ConvertibleExactlyWithSample Integer t) => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.
specHasIntegerBounds :: (Arbitrary t, Show t, CanTestFinite t, HasIntegerBounds t, HasOrderAsymmetric t Integer, HasOrderAsymmetric Integer t, CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType Integer t)) => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.