Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- type CanAddSubMulBy t s = (CanAddThis t s, CanSubThis t s, CanSub s t, SubType s t ~ t, CanMulBy t s)
- class (RingPre t, CanEnsureCN t, RingPre (EnsureCN t)) => Ring t
- class (Ring t, HasEq t t, HasEq (EnsureCN t) t, HasEq t (EnsureCN t), HasEq t Int, HasEq t Integer, HasEq (EnsureCN t) Int, HasEq (EnsureCN t) Integer, HasOrder t t, HasOrder (EnsureCN t) t, HasOrder t (EnsureCN t), HasOrder t Int, HasOrder t Integer, HasOrder (EnsureCN t) Int, HasOrder (EnsureCN t) Integer) => OrderedRing t
- class (Ring t, HasEqCertainly t t, HasEqCertainly (EnsureCN t) t, HasEqCertainly t (EnsureCN t), HasEqCertainly t Int, HasEq t Integer, HasEqCertainly (EnsureCN t) Int, HasEq (EnsureCN t) Integer, HasOrderCertainly t t, HasOrderCertainly (EnsureCN t) t, HasOrderCertainly t (EnsureCN t), HasOrderCertainly t Int, HasOrderCertainly t Integer, HasOrderCertainly (EnsureCN t) Int, HasOrderCertainly (EnsureCN t) Integer, CanTestPosNeg t) => OrderedCertainlyRing t
- type CanMul t1 t2 = (CanMulAsymmetric t1 t2, CanMulAsymmetric t2 t1, MulType t1 t2 ~ MulType t2 t1)
- class CanMulAsymmetric t1 t2 where
- type MulType t1 t2
- type CanMulBy t1 t2 = (CanMul t1 t2, MulType t1 t2 ~ t1)
- type CanMulSameType t = CanMulBy t t
- (*) :: CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
- product :: (CanMulSameType t, ConvertibleExactly Integer t) => [t] -> t
- specCanMul :: (Show t1, Show t2, Show t3, Show (MulType t1 t2), Show (MulType t2 t1), Show (MulType t1 (MulType t2 t3)), Show (MulType (MulType t1 t2) t3), Show (MulType t1 (AddType t2 t3)), Show (AddType (MulType t1 t2) (MulType t1 t3)), Arbitrary t1, Arbitrary t2, Arbitrary t3, ConvertibleExactly Integer t2, CanTestCertainly (EqCompareType (MulType t1 t2) t1), CanTestCertainly (EqCompareType (MulType t1 t2) (MulType t2 t1)), CanTestCertainly (EqCompareType (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3)), CanTestCertainly (EqCompareType (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3))), HasEqAsymmetric (MulType t1 t2) t1, HasEqAsymmetric (MulType t1 t2) (MulType t2 t1), HasEqAsymmetric (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3), HasEqAsymmetric (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3)), CanAddAsymmetric t2 t3, CanAddAsymmetric (MulType t1 t2) (MulType t1 t3), CanMulAsymmetric t1 t2, CanMulAsymmetric t1 t3, CanMulAsymmetric t1 (MulType t2 t3), CanMulAsymmetric t1 (AddType t2 t3), CanMulAsymmetric t2 t1, CanMulAsymmetric t2 t3, CanMulAsymmetric (MulType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec
- specCanMulNotMixed :: (Show t, Show (MulType t t), Show (MulType t (MulType t t)), Show (MulType (MulType t t) t), Show (MulType t (AddType t t)), Show (AddType (MulType t t) (MulType t t)), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (MulType t t) t), CanTestCertainly (EqCompareType (MulType t t) (MulType t t)), CanTestCertainly (EqCompareType (MulType t (MulType t t)) (MulType (MulType t t) t)), CanTestCertainly (EqCompareType (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t))), HasEqAsymmetric (MulType t t) t, HasEqAsymmetric (MulType t t) (MulType t t), HasEqAsymmetric (MulType t (MulType t t)) (MulType (MulType t t) t), HasEqAsymmetric (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)), CanAddAsymmetric t t, CanAddAsymmetric (MulType t t) (MulType t t), CanMulAsymmetric t t, CanMulAsymmetric t (MulType t t), CanMulAsymmetric t (AddType t t), CanMulAsymmetric (MulType t t) t) => T t -> Spec
- specCanMulSameType :: (Show t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType t t), HasEqAsymmetric t t, CanMulAsymmetric t t, MulType t t ~ t) => T t -> Spec
- class CanPow b e where
- type PowTypeNoCN b e
- type PowType b e
- type CanPowBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ t1, PowTypeNoCN t1 t2 ~ t1)
- type CanPowCNBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ EnsureCN t1, PowTypeNoCN t1 t2 ~ t1, CanEnsureCN t1, CanPow (EnsureCN t1) t2, PowType (EnsureCN t1) t2 ~ EnsureCN t1, PowTypeNoCN (EnsureCN t1) t2 ~ EnsureCN t1)
- (^) :: CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
- (^!) :: CanPow t1 t2 => t1 -> t2 -> PowTypeNoCN t1 t2
- powUsingMul :: (CanBeInteger e, CanMulSameType t) => t -> t -> e -> t
- integerPowCN :: (HasOrderCertainly b Integer, HasOrderCertainly e Integer, HasEqCertainly b Integer, HasEqCertainly e Integer, CanEnsureCN r) => (b -> e -> r) -> b -> e -> EnsureCN r
- specCanPow :: (Show t1, Show t2, Show (PowType t1 t2), Show (MulType t1 (PowType t1 t2)), Show (PowType t1 (AddType t2 Integer)), Arbitrary t1, Arbitrary t2, ConvertibleExactly Integer t1, ConvertibleExactly Integer t2, CanTestCertainly (EqCompareType (PowType t1 t2) t1), CanTestCertainly (EqCompareType (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))), HasEqAsymmetric (PowType t1 t2) t1, HasEqAsymmetric (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer)), CanTestPosNeg t2, CanAddAsymmetric t2 Integer, CanPow t1 t2, CanPow t1 (AddType t2 Integer), CanMulAsymmetric t1 (PowType t1 t2)) => T t1 -> T t2 -> Spec
Ring
type CanAddSubMulBy t s = (CanAddThis t s, CanSubThis t s, CanSub s t, SubType s t ~ t, CanMulBy t s) Source #
class (RingPre t, CanEnsureCN t, RingPre (EnsureCN t)) => Ring t Source #
class (Ring t, HasEq t t, HasEq (EnsureCN t) t, HasEq t (EnsureCN t), HasEq t Int, HasEq t Integer, HasEq (EnsureCN t) Int, HasEq (EnsureCN t) Integer, HasOrder t t, HasOrder (EnsureCN t) t, HasOrder t (EnsureCN t), HasOrder t Int, HasOrder t Integer, HasOrder (EnsureCN t) Int, HasOrder (EnsureCN t) Integer) => OrderedRing t Source #
class (Ring t, HasEqCertainly t t, HasEqCertainly (EnsureCN t) t, HasEqCertainly t (EnsureCN t), HasEqCertainly t Int, HasEq t Integer, HasEqCertainly (EnsureCN t) Int, HasEq (EnsureCN t) Integer, HasOrderCertainly t t, HasOrderCertainly (EnsureCN t) t, HasOrderCertainly t (EnsureCN t), HasOrderCertainly t Int, HasOrderCertainly t Integer, HasOrderCertainly (EnsureCN t) Int, HasOrderCertainly (EnsureCN t) Integer, CanTestPosNeg t) => OrderedCertainlyRing t Source #
Multiplication
type CanMul t1 t2 = (CanMulAsymmetric t1 t2, CanMulAsymmetric t2 t1, MulType t1 t2 ~ MulType t2 t1) Source #
class CanMulAsymmetric 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 *
.
mul :: t1 -> t2 -> MulType t1 t2 Source #
mul :: (MulType t1 t2 ~ t1, t1 ~ t2, Num t1) => t1 -> t2 -> MulType t1 t2 Source #
type CanMulSameType t = CanMulBy t t Source #
(*) :: CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2 infixl 7 Source #
product :: (CanMulSameType t, ConvertibleExactly Integer t) => [t] -> t Source #
Tests
specCanMul :: (Show t1, Show t2, Show t3, Show (MulType t1 t2), Show (MulType t2 t1), Show (MulType t1 (MulType t2 t3)), Show (MulType (MulType t1 t2) t3), Show (MulType t1 (AddType t2 t3)), Show (AddType (MulType t1 t2) (MulType t1 t3)), Arbitrary t1, Arbitrary t2, Arbitrary t3, ConvertibleExactly Integer t2, CanTestCertainly (EqCompareType (MulType t1 t2) t1), CanTestCertainly (EqCompareType (MulType t1 t2) (MulType t2 t1)), CanTestCertainly (EqCompareType (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3)), CanTestCertainly (EqCompareType (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3))), HasEqAsymmetric (MulType t1 t2) t1, HasEqAsymmetric (MulType t1 t2) (MulType t2 t1), HasEqAsymmetric (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3), HasEqAsymmetric (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3)), CanAddAsymmetric t2 t3, CanAddAsymmetric (MulType t1 t2) (MulType t1 t3), CanMulAsymmetric t1 t2, CanMulAsymmetric t1 t3, CanMulAsymmetric t1 (MulType t2 t3), CanMulAsymmetric t1 (AddType t2 t3), CanMulAsymmetric t2 t1, CanMulAsymmetric t2 t3, CanMulAsymmetric (MulType t1 t2) t3) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanMul should satisfy.
specCanMulNotMixed :: (Show t, Show (MulType t t), Show (MulType t (MulType t t)), Show (MulType (MulType t t) t), Show (MulType t (AddType t t)), Show (AddType (MulType t t) (MulType t t)), Arbitrary t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType (MulType t t) t), CanTestCertainly (EqCompareType (MulType t t) (MulType t t)), CanTestCertainly (EqCompareType (MulType t (MulType t t)) (MulType (MulType t t) t)), CanTestCertainly (EqCompareType (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t))), HasEqAsymmetric (MulType t t) t, HasEqAsymmetric (MulType t t) (MulType t t), HasEqAsymmetric (MulType t (MulType t t)) (MulType (MulType t t) t), HasEqAsymmetric (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)), CanAddAsymmetric t t, CanAddAsymmetric (MulType t t) (MulType t t), CanMulAsymmetric t t, CanMulAsymmetric t (MulType t t), CanMulAsymmetric t (AddType t t), CanMulAsymmetric (MulType t t) t) => T t -> Spec Source #
HSpec properties that each implementation of CanMul should satisfy.
specCanMulSameType :: (Show t, ConvertibleExactly Integer t, CanTestCertainly (EqCompareType t t), HasEqAsymmetric t t, CanMulAsymmetric t t, MulType t t ~ t) => T t -> Spec Source #
HSpec properties that each implementation of CanMulSameType should satisfy.
Exponentiation
class CanPow b e where Source #
A replacement for Prelude's binary ^
and ^^
. If Num t1
and Integral t2
,
then one can use the default implementation to mirror Prelude's ^
.
powNoCN :: b -> e -> PowTypeNoCN b e Source #
pow :: b -> e -> PowType b e Source #
pow :: (HasOrderCertainly b Integer, HasOrderCertainly e Integer, HasEqCertainly b Integer, CanTestInteger e, CanEnsureCN (PowTypeNoCN b e), PowType b e ~ EnsureCN (PowTypeNoCN b e)) => b -> e -> PowType b e Source #
type CanPowCNBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ EnsureCN t1, PowTypeNoCN t1 t2 ~ t1, CanEnsureCN t1, CanPow (EnsureCN t1) t2, PowType (EnsureCN t1) t2 ~ EnsureCN t1, PowTypeNoCN (EnsureCN t1) t2 ~ EnsureCN t1) Source #
(^!) :: CanPow t1 t2 => t1 -> t2 -> PowTypeNoCN t1 t2 infixl 8 Source #
Like ^
but throwing an exception if the power is undefined.
powUsingMul :: (CanBeInteger e, CanMulSameType t) => t -> t -> e -> t Source #
integerPowCN :: (HasOrderCertainly b Integer, HasOrderCertainly e Integer, HasEqCertainly b Integer, HasEqCertainly e Integer, CanEnsureCN r) => (b -> e -> r) -> b -> e -> EnsureCN r Source #
Tests
specCanPow :: (Show t1, Show t2, Show (PowType t1 t2), Show (MulType t1 (PowType t1 t2)), Show (PowType t1 (AddType t2 Integer)), Arbitrary t1, Arbitrary t2, ConvertibleExactly Integer t1, ConvertibleExactly Integer t2, CanTestCertainly (EqCompareType (PowType t1 t2) t1), CanTestCertainly (EqCompareType (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))), HasEqAsymmetric (PowType t1 t2) t1, HasEqAsymmetric (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer)), CanTestPosNeg t2, CanAddAsymmetric t2 Integer, CanPow t1 t2, CanPow t1 (AddType t2 Integer), CanMulAsymmetric t1 (PowType t1 t2)) => T t1 -> T t2 -> Spec Source #
HSpec properties that each implementation of CanPow should satisfy.