Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Numeric.MixedTypes.MinMaxAbs
Description
Synopsis
- type CanMinMax t1 t2 = (CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t2 t1, MinMaxType t1 t2 ~ MinMaxType t2 t1)
- class CanMinMaxAsymmetric t1 t2 where
- type MinMaxType t1 t2
- min :: t1 -> t2 -> MinMaxType t1 t2
- max :: t1 -> t2 -> MinMaxType t1 t2
- type CanMinMaxThis t1 t2 = (CanMinMax t1 t2, MinMaxType t1 t2 ~ t1)
- type CanMinMaxSameType t = CanMinMaxThis t t
- minimum :: CanMinMaxSameType t => [t] -> t
- maximum :: CanMinMaxSameType t => [t] -> t
- specCanMinMax :: (HasOrderAsymmetric (MinMaxType t1 t2) t2, HasOrderAsymmetric (MinMaxType t1 t2) t1, Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestFinite t1, CanTestFinite t2, CanTestFinite t3, HasEqAsymmetric (MinMaxType t1 t1) t1, HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1), HasEqAsymmetric (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3), CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t2), CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t1), CanTestCertainly (EqCompareType (MinMaxType t1 t1) t1), CanTestCertainly (EqCompareType (MinMaxType t1 t2) (MinMaxType t2 t1)), CanTestCertainly (EqCompareType (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3)), Show t1, Show t2, Show t3, Show (MinMaxType t2 t1), Show (MinMaxType t1 t2), Show (MinMaxType t1 t1), Show (MinMaxType t1 (MinMaxType t2 t3)), Show (MinMaxType (MinMaxType t1 t2) t3), CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t1 t1, CanMinMaxAsymmetric t1 (MinMaxType t2 t3), CanMinMaxAsymmetric t2 t1, CanMinMaxAsymmetric t2 t3, CanMinMaxAsymmetric (MinMaxType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec
- specCanMinMaxNotMixed :: (HasOrderAsymmetric (MinMaxType t t) t, Arbitrary t, CanTestFinite t, HasEqAsymmetric (MinMaxType t t) t, HasEqAsymmetric (MinMaxType t t) (MinMaxType t t), HasEqAsymmetric (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t), CanTestCertainly (OrderCompareType (MinMaxType t t) t), CanTestCertainly (EqCompareType (MinMaxType t t) t), CanTestCertainly (EqCompareType (MinMaxType t t) (MinMaxType t t)), CanTestCertainly (EqCompareType (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t)), Show t, Show (MinMaxType t t), Show (MinMaxType t (MinMaxType t t)), Show (MinMaxType (MinMaxType t t) t), CanMinMaxAsymmetric t t, CanMinMaxAsymmetric t (MinMaxType t t), CanMinMaxAsymmetric (MinMaxType t t) t) => T t -> Spec
- class CanAbs t where
- type CanAbsSameType t = (CanAbs t, AbsType t ~ t)
- specCanNegNum :: (Arbitrary t, Show t, Show (NegType (NegType t)), HasEqAsymmetric t t, HasEqAsymmetric (NegType t) t, HasEqAsymmetric (NegType (NegType t)) t, CanTestCertainly (EqCompareType t t), CanTestCertainly (EqCompareType (NegType t) t), CanTestCertainly (EqCompareType (NegType (NegType t)) t), CanTestFinite t, CanTestPosNeg t, CanTestPosNeg (NegType t), ConvertibleExactlyWithSample Integer t, CanNeg t, CanNeg (NegType t)) => T t -> Spec
- specCanAbs :: (Arbitrary t, CanAbs t, CanAbs (AbsType t), CanTestFinite t, HasEqAsymmetric t t, HasEqAsymmetric t (AbsType t), HasEqAsymmetric (AbsType (AbsType t)) (AbsType t), HasEqAsymmetric (NegType t) (AbsType t), CanTestCertainly (EqCompareType t t), CanTestCertainly (EqCompareType t (AbsType t)), CanTestCertainly (EqCompareType (AbsType (AbsType t)) (AbsType t)), CanTestCertainly (EqCompareType (NegType t) (AbsType t)), Show t, Show (AbsType t), Show (AbsType (AbsType t)), Show (NegType t), CanTestPosNeg t, CanTestPosNeg (AbsType t), CanNeg t) => T t -> Spec
Minimum and maximum
type CanMinMax t1 t2 = (CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t2 t1, MinMaxType t1 t2 ~ MinMaxType t2 t1) Source #
class CanMinMaxAsymmetric t1 t2 where Source #
A replacement for Prelude's min
and max
. If t1 = t2
and Ord t1
,
then one can use the default implementation to mirror Prelude's min
and max
.
Minimal complete definition
Nothing
Methods
min :: t1 -> t2 -> MinMaxType t1 t2 Source #
default min :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
max :: t1 -> t2 -> MinMaxType t1 t2 Source #
default max :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
Instances
type CanMinMaxThis t1 t2 = (CanMinMax t1 t2, MinMaxType t1 t2 ~ t1) Source #
type CanMinMaxSameType t = CanMinMaxThis t t Source #
minimum :: CanMinMaxSameType t => [t] -> t Source #
maximum :: CanMinMaxSameType t => [t] -> t Source #
Tests
specCanMinMax :: (HasOrderAsymmetric (MinMaxType t1 t2) t2, HasOrderAsymmetric (MinMaxType t1 t2) t1, Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestFinite t1, CanTestFinite t2, CanTestFinite t3, HasEqAsymmetric (MinMaxType t1 t1) t1, HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1), HasEqAsymmetric (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3), CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t2), CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t1), CanTestCertainly (EqCompareType (MinMaxType t1 t1) t1), CanTestCertainly (EqCompareType (MinMaxType t1 t2) (MinMaxType t2 t1)), CanTestCertainly (EqCompareType (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3)), Show t1, Show t2, Show t3, Show (MinMaxType t2 t1), Show (MinMaxType t1 t2), Show (MinMaxType t1 t1), Show (MinMaxType t1 (MinMaxType t2 t3)), Show (MinMaxType (MinMaxType t1 t2) t3), CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t1 t1, CanMinMaxAsymmetric t1 (MinMaxType t2 t3), CanMinMaxAsymmetric t2 t1, CanMinMaxAsymmetric t2 t3, CanMinMaxAsymmetric (MinMaxType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanMinMax should satisfy.
specCanMinMaxNotMixed :: (HasOrderAsymmetric (MinMaxType t t) t, Arbitrary t, CanTestFinite t, HasEqAsymmetric (MinMaxType t t) t, HasEqAsymmetric (MinMaxType t t) (MinMaxType t t), HasEqAsymmetric (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t), CanTestCertainly (OrderCompareType (MinMaxType t t) t), CanTestCertainly (EqCompareType (MinMaxType t t) t), CanTestCertainly (EqCompareType (MinMaxType t t) (MinMaxType t t)), CanTestCertainly (EqCompareType (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t)), Show t, Show (MinMaxType t t), Show (MinMaxType t (MinMaxType t t)), Show (MinMaxType (MinMaxType t t) t), CanMinMaxAsymmetric t t, CanMinMaxAsymmetric t (MinMaxType t t), CanMinMaxAsymmetric (MinMaxType t t) t) => T t -> Spec Source #
HSpec properties that each implementation of CanMinMax should satisfy.
Absolute value
A replacement for Prelude's abs
. If Num t
,
then one can use the default implementation to mirror Prelude's abs
.
Minimal complete definition
Nothing
Methods
Instances
CanAbs Rational Source # | |||||
CanAbs Integer Source # | |||||
CanAbs Double Source # | |||||
CanAbs Int Source # | |||||
(CanMulAsymmetric t t, CanAddSameType (MulType t t), CanSqrt (MulType t t)) => CanAbs (Complex t) Source # | |||||
(CanAbs a, CanBeErrors es) => CanAbs (CollectErrors es a) Source # | |||||
Defined in Numeric.MixedTypes.MinMaxAbs Associated Types
Methods abs :: CollectErrors es a -> AbsType (CollectErrors es a) Source # |
Tests
specCanNegNum :: (Arbitrary t, Show t, Show (NegType (NegType t)), HasEqAsymmetric t t, HasEqAsymmetric (NegType t) t, HasEqAsymmetric (NegType (NegType t)) t, CanTestCertainly (EqCompareType t t), CanTestCertainly (EqCompareType (NegType t) t), CanTestCertainly (EqCompareType (NegType (NegType t)) t), CanTestFinite t, CanTestPosNeg t, CanTestPosNeg (NegType t), ConvertibleExactlyWithSample Integer t, CanNeg t, CanNeg (NegType t)) => T t -> Spec Source #
HSpec properties that each numeric implementation of CanNeg should satisfy.
specCanAbs :: (Arbitrary t, CanAbs t, CanAbs (AbsType t), CanTestFinite t, HasEqAsymmetric t t, HasEqAsymmetric t (AbsType t), HasEqAsymmetric (AbsType (AbsType t)) (AbsType t), HasEqAsymmetric (NegType t) (AbsType t), CanTestCertainly (EqCompareType t t), CanTestCertainly (EqCompareType t (AbsType t)), CanTestCertainly (EqCompareType (AbsType (AbsType t)) (AbsType t)), CanTestCertainly (EqCompareType (NegType t) (AbsType t)), Show t, Show (AbsType t), Show (AbsType (AbsType t)), Show (NegType t), CanTestPosNeg t, CanTestPosNeg (AbsType t), CanNeg t) => T t -> Spec Source #
HSpec properties that each implementation of CanAbs should satisfy.