Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- 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
- 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 :: (Show t1, Show t2, Show t3, Show (MinMaxType t1 t2), Show (MinMaxType t1 t1), Show (MinMaxType t2 t1), Show (MinMaxType t1 (MinMaxType t2 t3)), Show (MinMaxType (MinMaxType t1 t2) t3), Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestCertainly (EqCompareType t1 t1), CanTestCertainly (EqCompareType t2 t2), 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 t3 t3), CanTestCertainly (EqCompareType (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3)), HasEqAsymmetric t1 t1, HasEqAsymmetric t2 t2, HasEqAsymmetric t3 t3, HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1), HasEqAsymmetric (MinMaxType t1 t1) t1, HasEqAsymmetric (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3), HasOrderAsymmetric (MinMaxType t1 t2) t1, HasOrderAsymmetric (MinMaxType t1 t2) t2, CanMinMaxAsymmetric t1 t1, CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t1 (MinMaxType t2 t3), CanMinMaxAsymmetric t2 t1, CanMinMaxAsymmetric t2 t3, CanMinMaxAsymmetric (MinMaxType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec
- specCanMinMaxNotMixed :: (Show t, Show (MinMaxType t t), Show (MinMaxType t (MinMaxType t t)), Show (MinMaxType (MinMaxType t t) t), Arbitrary t, CanTestCertainly (EqCompareType 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)), HasEqAsymmetric t t, HasEqAsymmetric (MinMaxType t t) t, HasEqAsymmetric (MinMaxType t t) (MinMaxType t t), HasEqAsymmetric (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t), HasOrderAsymmetric (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 AbsType t
- type CanAbsSameType t = (CanAbs t, AbsType t ~ t)
- specCanNegNum :: (CanNegX t, CanNegX (NegType t), HasEqCertainly t (NegType (NegType t)), ConvertibleExactly Integer t, HasEqCertainly t t, HasEqCertainly t (NegType t), CanTestPosNeg t, CanTestPosNeg (NegType t)) => T t -> Spec
- specCanAbs :: (CanAbsX t, CanAbsX (AbsType 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
.
type MinMaxType t1 t2 Source #
min :: t1 -> t2 -> MinMaxType t1 t2 Source #
max :: t1 -> t2 -> MinMaxType t1 t2 Source #
min :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
max :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
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 :: (Show t1, Show t2, Show t3, Show (MinMaxType t1 t2), Show (MinMaxType t1 t1), Show (MinMaxType t2 t1), Show (MinMaxType t1 (MinMaxType t2 t3)), Show (MinMaxType (MinMaxType t1 t2) t3), Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestCertainly (EqCompareType t1 t1), CanTestCertainly (EqCompareType t2 t2), 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 t3 t3), CanTestCertainly (EqCompareType (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3)), HasEqAsymmetric t1 t1, HasEqAsymmetric t2 t2, HasEqAsymmetric t3 t3, HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1), HasEqAsymmetric (MinMaxType t1 t1) t1, HasEqAsymmetric (MinMaxType t1 (MinMaxType t2 t3)) (MinMaxType (MinMaxType t1 t2) t3), HasOrderAsymmetric (MinMaxType t1 t2) t1, HasOrderAsymmetric (MinMaxType t1 t2) t2, CanMinMaxAsymmetric t1 t1, CanMinMaxAsymmetric t1 t2, 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 :: (Show t, Show (MinMaxType t t), Show (MinMaxType t (MinMaxType t t)), Show (MinMaxType (MinMaxType t t) t), Arbitrary t, CanTestCertainly (EqCompareType 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)), HasEqAsymmetric t t, HasEqAsymmetric (MinMaxType t t) t, HasEqAsymmetric (MinMaxType t t) (MinMaxType t t), HasEqAsymmetric (MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t), HasOrderAsymmetric (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
.
type CanAbsSameType t = (CanAbs t, AbsType t ~ t) Source #
Tests
specCanNegNum :: (CanNegX t, CanNegX (NegType t), HasEqCertainly t (NegType (NegType t)), ConvertibleExactly Integer t, HasEqCertainly t t, HasEqCertainly t (NegType t), CanTestPosNeg t, CanTestPosNeg (NegType t)) => T t -> Spec Source #
HSpec properties that each numeric implementation of CanNeg should satisfy.
specCanAbs :: (CanAbsX t, CanAbsX (AbsType t)) => T t -> Spec Source #
HSpec properties that each implementation of CanAbs should satisfy.