Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Numeric.MixedTypes.AddSub
Contents
Description
- type CanAdd t1 t2 = (CanAddAsymmetric t1 t2, CanAddAsymmetric t2 t1, AddType t1 t2 ~ AddType t2 t1)
- class CanAddAsymmetric t1 t2 where
- type AddType t1 t2
- type CanAddThis t1 t2 = (CanAdd t1 t2, AddType t1 t2 ~ t1)
- type CanAddSameType t = CanAddThis t t
- (+) :: CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
- sum :: (CanAddSameType t, ConvertibleExactly Integer t) => [t] -> t
- specCanAdd :: (Show t1, Show t2, Show t3, Show (AddType t1 t1), Show (AddType t1 t2), Show (AddType t2 t1), Show (AddType t1 (AddType t2 t3)), Show (AddType (AddType t1 t2) t3), Arbitrary t1, Arbitrary t2, Arbitrary t3, ConvertibleExactly Integer t1, CanTestCertainly (EqCompareType (AddType t1 t1) t1), CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)), CanTestCertainly (EqCompareType (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)), CanTestCertainly (OrderCompareType (AddType t1 t2) t2), HasEqAsymmetric (AddType t1 t1) t1, HasEqAsymmetric (AddType t1 t2) (AddType t2 t1), HasEqAsymmetric (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3), HasOrderAsymmetric (AddType t1 t2) t2, CanTestPosNeg t1, CanAddAsymmetric t1 t1, CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3), CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3, CanAddAsymmetric (AddType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec
- specCanAddNotMixed :: (Show t, Show (AddType t t), Show (AddType t (AddType t t)), Show (AddType (AddType t t) t), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (AddType t t) t), CanTestCertainly (EqCompareType (AddType t t) (AddType t t)), CanTestCertainly (EqCompareType (AddType t (AddType t t)) (AddType (AddType t t) t)), CanTestCertainly (OrderCompareType (AddType t t) t), HasEqAsymmetric (AddType t t) t, HasEqAsymmetric (AddType t t) (AddType t t), HasEqAsymmetric (AddType t (AddType t t)) (AddType (AddType t t) t), HasOrderAsymmetric (AddType t t) t, CanTestPosNeg t, CanAddAsymmetric t t, CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t) => T t -> Spec
- specCanAddSameType :: (ConvertibleExactly Integer t, Show t, HasEqCertainly t t, CanAddSameType t) => T t -> Spec
- class CanSub t1 t2 where
- type SubType t1 t2
- type CanSubThis t1 t2 = (CanSub t1 t2, SubType t1 t2 ~ t1)
- type CanSubSameType t = CanSubThis t t
- (-) :: CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- specCanSub :: (Show t1, Show t2, Show (SubType t1 t1), Show (SubType t1 t2), Show (AddType t1 (NegType t2)), Arbitrary t1, Arbitrary t2, ConvertibleExactly Integer t1, CanTestCertainly (EqCompareType (SubType t1 t1) t1), CanTestCertainly (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))), CanNeg t2, HasEqAsymmetric (SubType t1 t1) t1, HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2, CanAddAsymmetric t1 (NegType t2)) => T t1 -> T t2 -> Spec
- specCanSubNotMixed :: (Show t, Show (SubType t t), Show (AddType t (NegType t)), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (SubType t t) t), CanTestCertainly (EqCompareType (SubType t t) (AddType t (NegType t))), CanNeg t, HasEqAsymmetric (SubType t t) t, HasEqAsymmetric (SubType t t) (AddType t (NegType t)), CanSub t t, CanAddAsymmetric t (NegType t)) => T t -> Spec
Addition
type CanAdd t1 t2 = (CanAddAsymmetric t1 t2, CanAddAsymmetric t2 t1, AddType t1 t2 ~ AddType t2 t1) Source #
class CanAddAsymmetric t1 t2 where Source #
A replacement for Prelude's +
. If t1 = t2
and Num t1
,
then one can use the default implementation to mirror Prelude's +
.
Methods
add :: t1 -> t2 -> AddType t1 t2 Source #
add :: (AddType t1 t2 ~ t1, t1 ~ t2, Num t1) => t1 -> t2 -> AddType t1 t2 Source #
Instances
type CanAddThis t1 t2 = (CanAdd t1 t2, AddType t1 t2 ~ t1) Source #
type CanAddSameType t = CanAddThis t t Source #
(+) :: CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2 infixl 6 Source #
sum :: (CanAddSameType t, ConvertibleExactly Integer t) => [t] -> t Source #
Tests
specCanAdd :: (Show t1, Show t2, Show t3, Show (AddType t1 t1), Show (AddType t1 t2), Show (AddType t2 t1), Show (AddType t1 (AddType t2 t3)), Show (AddType (AddType t1 t2) t3), Arbitrary t1, Arbitrary t2, Arbitrary t3, ConvertibleExactly Integer t1, CanTestCertainly (EqCompareType (AddType t1 t1) t1), CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)), CanTestCertainly (EqCompareType (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)), CanTestCertainly (OrderCompareType (AddType t1 t2) t2), HasEqAsymmetric (AddType t1 t1) t1, HasEqAsymmetric (AddType t1 t2) (AddType t2 t1), HasEqAsymmetric (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3), HasOrderAsymmetric (AddType t1 t2) t2, CanTestPosNeg t1, CanAddAsymmetric t1 t1, CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3), CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3, CanAddAsymmetric (AddType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanAdd should satisfy.
specCanAddNotMixed :: (Show t, Show (AddType t t), Show (AddType t (AddType t t)), Show (AddType (AddType t t) t), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (AddType t t) t), CanTestCertainly (EqCompareType (AddType t t) (AddType t t)), CanTestCertainly (EqCompareType (AddType t (AddType t t)) (AddType (AddType t t) t)), CanTestCertainly (OrderCompareType (AddType t t) t), HasEqAsymmetric (AddType t t) t, HasEqAsymmetric (AddType t t) (AddType t t), HasEqAsymmetric (AddType t (AddType t t)) (AddType (AddType t t) t), HasOrderAsymmetric (AddType t t) t, CanTestPosNeg t, CanAddAsymmetric t t, CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t) => T t -> Spec Source #
HSpec properties that each implementation of CanAdd should satisfy.
specCanAddSameType :: (ConvertibleExactly Integer t, Show t, HasEqCertainly t t, CanAddSameType t) => T t -> Spec Source #
HSpec properties that each implementation of CanAddSameType should satisfy.
Subtraction
class CanSub t1 t2 where Source #
A replacement for Prelude's binary -
.
If CanNeg t2
and CanAdd t1 (NegType t2)
,
then one can use the default implementation
via a-b = a + (-b)
.
Methods
sub :: t1 -> t2 -> SubType t1 t2 Source #
sub :: (SubType t1 t2 ~ AddType t1 (NegType t2), CanNeg t2, CanAdd t1 (NegType t2)) => t1 -> t2 -> SubType t1 t2 Source #
Instances
type CanSubThis t1 t2 = (CanSub t1 t2, SubType t1 t2 ~ t1) Source #
type CanSubSameType t = CanSubThis t t Source #
Tests
specCanSub :: (Show t1, Show t2, Show (SubType t1 t1), Show (SubType t1 t2), Show (AddType t1 (NegType t2)), Arbitrary t1, Arbitrary t2, ConvertibleExactly Integer t1, CanTestCertainly (EqCompareType (SubType t1 t1) t1), CanTestCertainly (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))), CanNeg t2, HasEqAsymmetric (SubType t1 t1) t1, HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2, CanAddAsymmetric t1 (NegType t2)) => T t1 -> T t2 -> Spec Source #
HSpec properties that each implementation of CanSub should satisfy.
specCanSubNotMixed :: (Show t, Show (SubType t t), Show (AddType t (NegType t)), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (SubType t t) t), CanTestCertainly (EqCompareType (SubType t t) (AddType t (NegType t))), CanNeg t, HasEqAsymmetric (SubType t t) t, HasEqAsymmetric (SubType t t) (AddType t (NegType t)), CanSub t t, CanAddAsymmetric t (NegType t)) => T t -> Spec Source #
HSpec properties that each implementation of CanSub should satisfy.