Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
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 :: _ => T t -> Spec
- specCanRound :: _ => T t -> Spec
- specHasIntegerBounds :: _ => T t -> Spec
Rounded division + modulus
class CanDivIMod t1 t2 where Source #
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
.
Nothing
properFraction :: t -> (RoundType t, t) Source #
truncate :: t -> RoundType t Source #
round :: t -> RoundType t Source #
Instances
CanRound Double Source # | |
Defined in Numeric.MixedTypes.Round | |
CanRound Rational Source # | |
Defined in Numeric.MixedTypes.Round |
class HasIntegerBounds t where Source #
Nothing
integerBounds :: t -> (Integer, Integer) Source #
Instances
HasIntegerBounds Double Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Int Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Integer Source # | |
Defined in Numeric.MixedTypes.Round | |
HasIntegerBounds Rational Source # | |
Defined in Numeric.MixedTypes.Round |
Tests
specCanDivIMod :: _ => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.
specCanRound :: _ => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.
specHasIntegerBounds :: _ => T t -> Spec Source #
HSpec properties that each implementation of CanRound should satisfy.