Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Numeric.MixedTypes.Eq
Description
- type HasEq t1 t2 = (HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, EqCompareType t1 t2 ~ EqCompareType t2 t1)
- class IsBool (EqCompareType a b) => HasEqAsymmetric a b where
- type EqCompareType a b
- (==) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b
- (/=) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b
- type HasEqCertainly t1 t2 = (HasEq t1 t2, CanTestCertainly (EqCompareType t1 t2))
- type HasEqCertainlyAsymmetric t1 t2 = (HasEqAsymmetric t1 t2, CanTestCertainly (EqCompareType t1 t2))
- type HasEqCertainlyCE es t1 t2 = (HasEqCertainly t1 t2, HasEqCertainly (EnsureCE es t1) (EnsureCE es t2))
- type HasEqCertainlyCN t1 t2 = HasEqCertainlyCE NumErrors t1 t2
- notCertainlyDifferentFrom :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- certainlyEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- certainlyNotEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (?==?) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (!==!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- (!/=!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool
- specHasEq :: (Show t1, Show t2, Show t3, Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestCertainly (EqCompareType t1 t1), CanTestCertainly (EqCompareType t1 t2), CanTestCertainly (EqCompareType t2 t1), CanTestCertainly (EqCompareType t2 t3), CanTestCertainly (AndOrType (EqCompareType t1 t2) (EqCompareType t2 t3)), CanAndOrAsymmetric (EqCompareType t1 t2) (EqCompareType t2 t3), HasEqAsymmetric t1 t1, HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, HasEqAsymmetric t2 t3) => T t1 -> T t2 -> T t3 -> Spec
- specHasEqNotMixed :: (Show t, Arbitrary t, CanTestCertainly (EqCompareType t t), CanTestCertainly (AndOrType (EqCompareType t t) (EqCompareType t t)), HasEqAsymmetric t t) => T t -> Spec
- specConversion :: (Arbitrary t1, Show t1, HasEqCertainly t1 t1) => T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec
- class CanTestNaN t where
- class CanTestFinite t where
- class CanTestInteger t where
- class CanTestZero t where
- specCanTestZero :: (CanTestZero t, ConvertibleExactly Integer t) => T t -> Spec
- class CanPickNonZero t where
- specCanPickNonZero :: (CanPickNonZero t, CanTestZero t, ConvertibleExactly Integer t, Show t, Arbitrary t) => T t -> Spec
Equality checks
type HasEq t1 t2 = (HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, EqCompareType t1 t2 ~ EqCompareType t2 t1) Source #
class IsBool (EqCompareType a b) => HasEqAsymmetric a b where Source #
Associated Types
type EqCompareType a b Source #
Methods
equalTo :: a -> b -> EqCompareType a b Source #
equalTo :: (EqCompareType a b ~ Bool, a ~ b, Eq a) => a -> b -> EqCompareType a b Source #
notEqualTo :: a -> b -> EqCompareType a b Source #
notEqualTo :: CanNegSameType (EqCompareType a b) => a -> b -> EqCompareType a b Source #
Instances
(==) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 Source #
(/=) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 Source #
type HasEqCertainly t1 t2 = (HasEq t1 t2, CanTestCertainly (EqCompareType t1 t2)) Source #
type HasEqCertainlyAsymmetric t1 t2 = (HasEqAsymmetric t1 t2, CanTestCertainly (EqCompareType t1 t2)) Source #
type HasEqCertainlyCE es t1 t2 = (HasEqCertainly t1 t2, HasEqCertainly (EnsureCE es t1) (EnsureCE es t2)) Source #
type HasEqCertainlyCN t1 t2 = HasEqCertainlyCE NumErrors t1 t2 Source #
notCertainlyDifferentFrom :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
certainlyEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
certainlyNotEqualTo :: HasEqCertainlyAsymmetric a b => a -> b -> Bool Source #
(?==?) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
(!==!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
(!/=!) :: HasEqCertainlyAsymmetric a b => a -> b -> Bool infix 4 Source #
Tests
specHasEq :: (Show t1, Show t2, Show t3, Arbitrary t1, Arbitrary t2, Arbitrary t3, CanTestCertainly (EqCompareType t1 t1), CanTestCertainly (EqCompareType t1 t2), CanTestCertainly (EqCompareType t2 t1), CanTestCertainly (EqCompareType t2 t3), CanTestCertainly (AndOrType (EqCompareType t1 t2) (EqCompareType t2 t3)), CanAndOrAsymmetric (EqCompareType t1 t2) (EqCompareType t2 t3), HasEqAsymmetric t1 t1, HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, HasEqAsymmetric t2 t3) => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of HasEq should satisfy.
specHasEqNotMixed :: (Show t, Arbitrary t, CanTestCertainly (EqCompareType t t), CanTestCertainly (AndOrType (EqCompareType t t) (EqCompareType t t)), HasEqAsymmetric t t) => T t -> Spec Source #
HSpec properties that each implementation of HasEq should satisfy.
specConversion :: (Arbitrary t1, Show t1, HasEqCertainly t1 t1) => T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec Source #
HSpec property of there-and-back conversion.
Specific comparisons
class CanTestNaN t where Source #
Instances
CanTestNaN Double Source # | |
CanTestNaN Rational Source # | |
(CanTestNaN t, SuitableForCE es) => CanTestNaN (CollectErrors es t) Source # | |
class CanTestFinite t where Source #
Methods
isInfinite :: t -> Bool Source #
isInfinite :: RealFloat t => t -> Bool Source #
Instances
CanTestFinite Double Source # | |
CanTestFinite Rational Source # | |
(CanTestFinite t, SuitableForCE es) => CanTestFinite (CollectErrors es t) Source # | |
class CanTestInteger t where Source #
Minimal complete definition
Methods
certainlyNotInteger :: t -> Bool Source #
certainlyInteger :: t -> Bool Source #
certainlyIntegerGetIt :: t -> Maybe Integer Source #
Instances
class CanTestZero t where Source #
Methods
isCertainlyZero :: t -> Bool Source #
isCertainlyNonZero :: t -> Bool Source #
isCertainlyZero :: HasEqCertainly t Integer => t -> Bool Source #
isCertainlyNonZero :: HasEqCertainly t Integer => t -> Bool Source #
Instances
CanTestZero Double Source # | |
CanTestZero Int Source # | |
CanTestZero Integer Source # | |
CanTestZero Rational Source # | |
(CanTestZero t, SuitableForCE es) => CanTestZero (CollectErrors es t) Source # | |
specCanTestZero :: (CanTestZero t, ConvertibleExactly Integer t) => T t -> Spec Source #
HSpec properties that each implementation of CanTestZero should satisfy.
class CanPickNonZero t where Source #
Methods
pickNonZero :: [(t, s)] -> Maybe (t, s) Source #
Given a list [(a1,b1),(a2,b2),...]
and assuming that
at least one of a1,a2,...
is non-zero, pick one of them
and return the corresponding pair (ai,bi)
.
If none of a1,a2,...
is zero, either throws an exception
or loops forever.
The default implementation is based on a CanTestZero
instance
and is not parallel.
pickNonZero :: (CanTestZero t, Show t) => [(t, s)] -> Maybe (t, s) Source #
Given a list [(a1,b1),(a2,b2),...]
and assuming that
at least one of a1,a2,...
is non-zero, pick one of them
and return the corresponding pair (ai,bi)
.
If none of a1,a2,...
is zero, either throws an exception
or loops forever.
The default implementation is based on a CanTestZero
instance
and is not parallel.
Instances
specCanPickNonZero :: (CanPickNonZero t, CanTestZero t, ConvertibleExactly Integer t, Show t, Arbitrary t) => T t -> Spec Source #
HSpec properties that each implementation of CanPickNonZero should satisfy.