Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Numeric.MixedTypes.AddSub
Contents
Description
Synopsis
- type CanAdd t1 t2 = (CanAddAsymmetric t1 t2, CanAddAsymmetric t2 t1, AddType t1 t2 ~ AddType t2 t1)
- class CanAddAsymmetric t1 t2 where
- 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
- sumWithSample :: (CanAddSameType t, ConvertibleExactlyWithSample Integer t) => t -> [t] -> t
- specCanAdd :: (Arbitrary t1, Arbitrary t2, Arbitrary t3, HasEqAsymmetric (AddType t1 t2) t1, HasEqAsymmetric (AddType t1 t2) (AddType t2 t1), HasEqAsymmetric (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3), Show t1, Show t2, Show t3, Show (AddType t2 t1), Show (AddType t1 t2), Show (AddType t1 (AddType t2 t3)), Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3), CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3, CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1, HasOrderAsymmetric (AddType t1 t2) t2, CanTestCertainly (EqCompareType (AddType t1 t2) 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), ConvertibleExactlyWithSample Integer t2) => T t1 -> T t2 -> T t3 -> Spec
- specCanAddNotMixed :: (Arbitrary t, HasEqAsymmetric (AddType t t) t, HasEqAsymmetric (AddType t t) (AddType t t), HasEqAsymmetric (AddType t (AddType t t)) (AddType (AddType t t) t), Show t, Show (AddType t t), Show (AddType t (AddType t t)), Show (AddType (AddType t t) t), CanAddAsymmetric t t, CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t, CanTestPosNeg t, HasOrderAsymmetric (AddType t t) 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), ConvertibleExactlyWithSample Integer t) => T t -> Spec
- specCanAddSameType :: (ConvertibleExactlyWithSample Integer t, Show t, HasEqCertainly t t, CanAddSameType t, Arbitrary t) => T t -> Spec
- class CanSub t1 t2 where
- 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 :: (Arbitrary t1, Arbitrary t2, Arbitrary (SubType t1 t1), CanSub t1 t2, CanSub t1 t1, HasEqAsymmetric (SubType t1 t1) (SubType t1 t1), HasEqAsymmetric (SubType t1 t2) t1, HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)), CanTestCertainly (EqCompareType (SubType t1 t1) (SubType t1 t1)), CanTestCertainly (EqCompareType (SubType t1 t2) t1), CanTestCertainly (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))), Show t1, Show t2, Show (SubType t1 t2), Show (SubType t1 t1), Show (AddType t1 (NegType t2)), CanAddAsymmetric t1 (NegType t2), ConvertibleExactlyWithSample Integer t2, ConvertibleExactlyWithSample Integer (SubType t1 t1), CanNeg t2) => T t1 -> T t2 -> Spec
- specCanSubNotMixed :: (Arbitrary t, Arbitrary (SubType t t), CanSub t t, HasEqAsymmetric (SubType t t) t, HasEqAsymmetric (SubType t t) (SubType t t), HasEqAsymmetric (SubType t t) (AddType t (NegType t)), CanTestCertainly (EqCompareType (SubType t t) t), CanTestCertainly (EqCompareType (SubType t t) (SubType t t)), CanTestCertainly (EqCompareType (SubType t t) (AddType t (NegType t))), Show t, Show (SubType t t), Show (AddType t (NegType t)), CanAddAsymmetric t (NegType t), ConvertibleExactlyWithSample Integer t, ConvertibleExactlyWithSample Integer (SubType t t), CanNeg 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 +
.
Minimal complete definition
Nothing
Methods
Instances
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 #
sumWithSample :: (CanAddSameType t, ConvertibleExactlyWithSample Integer t) => t -> [t] -> t Source #
Tests
specCanAdd :: (Arbitrary t1, Arbitrary t2, Arbitrary t3, HasEqAsymmetric (AddType t1 t2) t1, HasEqAsymmetric (AddType t1 t2) (AddType t2 t1), HasEqAsymmetric (AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3), Show t1, Show t2, Show t3, Show (AddType t2 t1), Show (AddType t1 t2), Show (AddType t1 (AddType t2 t3)), Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3), CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3, CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1, HasOrderAsymmetric (AddType t1 t2) t2, CanTestCertainly (EqCompareType (AddType t1 t2) 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), ConvertibleExactlyWithSample Integer t2) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanAdd should satisfy.
specCanAddNotMixed :: (Arbitrary t, HasEqAsymmetric (AddType t t) t, HasEqAsymmetric (AddType t t) (AddType t t), HasEqAsymmetric (AddType t (AddType t t)) (AddType (AddType t t) t), Show t, Show (AddType t t), Show (AddType t (AddType t t)), Show (AddType (AddType t t) t), CanAddAsymmetric t t, CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t, CanTestPosNeg t, HasOrderAsymmetric (AddType t t) 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), ConvertibleExactlyWithSample Integer t) => T t -> Spec Source #
HSpec properties that each implementation of CanAdd should satisfy.
specCanAddSameType :: (ConvertibleExactlyWithSample Integer t, Show t, HasEqCertainly t t, CanAddSameType t, Arbitrary 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)
.
Minimal complete definition
Nothing
Methods
Instances
CanSub Rational Rational Source # | |||||
CanSub Rational Integer Source # | |||||
CanSub Rational Double Source # | |||||
CanSub Rational Int Source # | |||||
CanSub Integer Rational Source # | |||||
CanSub Integer Integer Source # | |||||
CanSub Integer Double Source # | |||||
CanSub Integer Int Source # | |||||
CanSub Double Rational Source # | |||||
CanSub Double Integer Source # | |||||
CanSub Double Double Source # | |||||
CanSub Double Int Source # | |||||
CanSub Int Rational Source # | |||||
CanSub Int Integer Source # | |||||
CanSub Int Double Source # | |||||
CanSub Int Int Source # | |||||
CanSub Rational b => CanSub Rational (Complex b) Source # | |||||
CanSub Integer b => CanSub Integer (Complex b) Source # | |||||
CanSub Double b => CanSub Double (Complex b) Source # | |||||
CanSub Int b => CanSub Int (Complex b) Source # | |||||
(CanSub Rational b, CanBeErrors es) => CanSub Rational (CollectErrors es b) Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: Rational -> CollectErrors es b -> SubType Rational (CollectErrors es b) Source # | |||||
(CanSub Integer b, CanBeErrors es) => CanSub Integer (CollectErrors es b) Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: Integer -> CollectErrors es b -> SubType Integer (CollectErrors es b) Source # | |||||
(CanSub Double b, CanBeErrors es) => CanSub Double (CollectErrors es b) Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: Double -> CollectErrors es b -> SubType Double (CollectErrors es b) Source # | |||||
(CanSub Int b, CanBeErrors es) => CanSub Int (CollectErrors es b) Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: Int -> CollectErrors es b -> SubType Int (CollectErrors es b) Source # | |||||
CanSub a Rational => CanSub (Complex a) Rational Source # | |||||
CanSub a Integer => CanSub (Complex a) Integer Source # | |||||
CanSub a Double => CanSub (Complex a) Double Source # | |||||
CanSub a Int => CanSub (Complex a) Int Source # | |||||
CanSub a b => CanSub (Complex a) (Complex b) Source # | |||||
CanSub a b => CanSub (Maybe a) (Maybe b) Source # | |||||
CanSub a b => CanSub [a] [b] Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
| |||||
(CanSub a Rational, CanBeErrors es) => CanSub (CollectErrors es a) Rational Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: CollectErrors es a -> Rational -> SubType (CollectErrors es a) Rational Source # | |||||
(CanSub a Integer, CanBeErrors es) => CanSub (CollectErrors es a) Integer Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: CollectErrors es a -> Integer -> SubType (CollectErrors es a) Integer Source # | |||||
(CanSub a Double, CanBeErrors es) => CanSub (CollectErrors es a) Double Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: CollectErrors es a -> Double -> SubType (CollectErrors es a) Double Source # | |||||
(CanSub a Int, CanBeErrors es) => CanSub (CollectErrors es a) Int Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: CollectErrors es a -> Int -> SubType (CollectErrors es a) Int Source # | |||||
(CanSub a b, CanBeErrors es) => CanSub (CollectErrors es a) (CollectErrors es b) Source # | |||||
Defined in Numeric.MixedTypes.AddSub Associated Types
Methods sub :: CollectErrors es a -> CollectErrors es b -> SubType (CollectErrors es a) (CollectErrors es b) Source # |
type CanSubSameType t = CanSubThis t t Source #
Tests
specCanSub :: (Arbitrary t1, Arbitrary t2, Arbitrary (SubType t1 t1), CanSub t1 t2, CanSub t1 t1, HasEqAsymmetric (SubType t1 t1) (SubType t1 t1), HasEqAsymmetric (SubType t1 t2) t1, HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)), CanTestCertainly (EqCompareType (SubType t1 t1) (SubType t1 t1)), CanTestCertainly (EqCompareType (SubType t1 t2) t1), CanTestCertainly (EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))), Show t1, Show t2, Show (SubType t1 t2), Show (SubType t1 t1), Show (AddType t1 (NegType t2)), CanAddAsymmetric t1 (NegType t2), ConvertibleExactlyWithSample Integer t2, ConvertibleExactlyWithSample Integer (SubType t1 t1), CanNeg t2) => T t1 -> T t2 -> Spec Source #
HSpec properties that each implementation of CanSub should satisfy.
specCanSubNotMixed :: (Arbitrary t, Arbitrary (SubType t t), CanSub t t, HasEqAsymmetric (SubType t t) t, HasEqAsymmetric (SubType t t) (SubType t t), HasEqAsymmetric (SubType t t) (AddType t (NegType t)), CanTestCertainly (EqCompareType (SubType t t) t), CanTestCertainly (EqCompareType (SubType t t) (SubType t t)), CanTestCertainly (EqCompareType (SubType t t) (AddType t (NegType t))), Show t, Show (SubType t t), Show (AddType t (NegType t)), CanAddAsymmetric t (NegType t), ConvertibleExactlyWithSample Integer t, ConvertibleExactlyWithSample Integer (SubType t t), CanNeg t) => T t -> Spec Source #
HSpec properties that each implementation of CanSub should satisfy.