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, CanMulBy t s)
- type Ring t = (CanNegSameType t, CanAddSameType t, CanSubSameType t, CanMulSameType t, CanPowBy t Integer, CanPowBy t Int, HasEq t t, HasEq t Integer, CanAddSubMulBy t Integer, CanSub Integer t, SubType Integer t ~ t, HasEq t Int, CanAddSubMulBy t Int, CanSub Int t, SubType Int t ~ t, ConvertibleExactly Integer t)
- type CertainlyEqRing t = (Ring t, HasEqCertainly t t, HasEqCertainly t Int, HasEqCertainly t Integer)
- type OrderedRing t = (Ring t, HasOrder t t, HasOrder t Int, HasOrder t Integer)
- type OrderedCertainlyRing t = (CertainlyEqRing t, HasOrderCertainly t t, HasOrderCertainly t Int, HasOrderCertainly t Integer, CanTestPosNeg 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 :: (CanMulX t1 t2, CanMulX t1 t3, CanMulX t2 t3, CanMulX t1 (MulType t2 t3), CanMulX (MulType t1 t2) t3, HasEqCertainly (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3), CanAdd t2 t3, CanMulX t1 (AddType t2 t3), CanAddX (MulType t1 t2) (MulType t1 t3), HasEqCertainly (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3)), ConvertibleExactly Integer t2) => T t1 -> T t2 -> T t3 -> Spec
- specCanMulNotMixed :: (CanMulX t t, CanMulX t (MulType t t), HasEqCertainly (MulType (MulType t t) t) (MulType t (MulType t t)), CanAdd t t, CanMulX t (AddType t t), CanAddX (MulType t t) (MulType t t), HasEqCertainly (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)), ConvertibleExactly Integer t) => T t -> Spec
- specCanMulSameType :: (ConvertibleExactly Integer t, Show t, HasEqCertainly t t, CanMulSameType t) => T t -> Spec
- type CanMulX t1 t2 = (CanMul t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2, Show (MulType t1 t2), HasEqCertainly t1 (MulType t1 t2), HasEqCertainly t2 (MulType t1 t2), HasEqCertainly (MulType t1 t2) (MulType t1 t2), HasOrderCertainly t1 (MulType t1 t2), HasOrderCertainly t2 (MulType t1 t2), HasOrderCertainly (MulType t1 t2) (MulType t1 t2))
- class CanPow t1 t2 where
- type PowType t1 t2
- type CanPowBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ t1)
- (^) :: CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
- (^^) :: CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
- (**) :: CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
- powUsingMul :: (CanBeInteger e, CanMulSameType t, ConvertibleExactly Integer t) => t -> e -> t
- specCanPow :: (CanPowX t1 t2, HasEqCertainly t1 (PowType t1 t2), ConvertibleExactly Integer t1, ConvertibleExactly Integer t2, CanTestPosNeg t2, CanAdd t2 Integer, CanMulX t1 (PowType t1 t2), CanPowX t1 (AddType t2 Integer), HasEqCertainly (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))) => T t1 -> T t2 -> Spec
- type CanPowX t1 t2 = (CanPow t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2, Show (PowType t1 t2))
Ring
type CanAddSubMulBy t s = (CanAddThis t s, CanSubThis t s, CanMulBy t s) Source #
type Ring t = (CanNegSameType t, CanAddSameType t, CanSubSameType t, CanMulSameType t, CanPowBy t Integer, CanPowBy t Int, HasEq t t, HasEq t Integer, CanAddSubMulBy t Integer, CanSub Integer t, SubType Integer t ~ t, HasEq t Int, CanAddSubMulBy t Int, CanSub Int t, SubType Int t ~ t, ConvertibleExactly Integer t) Source #
type CertainlyEqRing t = (Ring t, HasEqCertainly t t, HasEqCertainly t Int, HasEqCertainly t Integer) Source #
type OrderedCertainlyRing t = (CertainlyEqRing t, HasOrderCertainly t t, HasOrderCertainly t Int, HasOrderCertainly t Integer, CanTestPosNeg 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 -> t1 -> t1 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 :: (CanMulX t1 t2, CanMulX t1 t3, CanMulX t2 t3, CanMulX t1 (MulType t2 t3), CanMulX (MulType t1 t2) t3, HasEqCertainly (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3), CanAdd t2 t3, CanMulX t1 (AddType t2 t3), CanAddX (MulType t1 t2) (MulType t1 t3), HasEqCertainly (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3)), ConvertibleExactly Integer t2) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanMul should satisfy.
specCanMulNotMixed :: (CanMulX t t, CanMulX t (MulType t t), HasEqCertainly (MulType (MulType t t) t) (MulType t (MulType t t)), CanAdd t t, CanMulX t (AddType t t), CanAddX (MulType t t) (MulType t t), HasEqCertainly (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)), ConvertibleExactly Integer t) => T t -> Spec Source #
HSpec properties that each implementation of CanMul should satisfy.
specCanMulSameType :: (ConvertibleExactly Integer t, Show t, HasEqCertainly t t, CanMulSameType t) => T t -> Spec Source #
HSpec properties that each implementation of CanMulSameType should satisfy.
type CanMulX t1 t2 = (CanMul t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2, Show (MulType t1 t2), HasEqCertainly t1 (MulType t1 t2), HasEqCertainly t2 (MulType t1 t2), HasEqCertainly (MulType t1 t2) (MulType t1 t2), HasOrderCertainly t1 (MulType t1 t2), HasOrderCertainly t2 (MulType t1 t2), HasOrderCertainly (MulType t1 t2) (MulType t1 t2)) Source #
Compound type constraint useful for test definition.
Exponentiation
class CanPow t1 t2 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 ^
.
powUsingMul :: (CanBeInteger e, CanMulSameType t, ConvertibleExactly Integer t) => t -> e -> t Source #
Tests
specCanPow :: (CanPowX t1 t2, HasEqCertainly t1 (PowType t1 t2), ConvertibleExactly Integer t1, ConvertibleExactly Integer t2, CanTestPosNeg t2, CanAdd t2 Integer, CanMulX t1 (PowType t1 t2), CanPowX t1 (AddType t2 Integer), HasEqCertainly (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))) => T t1 -> T t2 -> Spec Source #
HSpec properties that each implementation of CanPow should satisfy.