mixed-types-num-0.6.2: Alternative Prelude with numeric and logic expressions typed bottom-up
Copyright(c) Michal Konecny
LicenseBSD3
Maintainer[email protected]
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Numeric.MixedTypes.Eq

Description

 
Synopsis

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 #

Minimal complete definition

Nothing

Associated Types

type EqCompareType a b Source #

type EqCompareType a b = Bool

Methods

equalTo :: a -> b -> EqCompareType a b Source #

default equalTo :: (EqCompareType a b ~ Bool, a ~ b, Eq a) => a -> b -> EqCompareType a b Source #

notEqualTo :: a -> b -> EqCompareType a b Source #

default notEqualTo :: CanNegSameType (EqCompareType a b) => a -> b -> EqCompareType a b Source #

Instances

Instances details
HasEqAsymmetric Rational Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Rational Rational 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Rational Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Rational Integer 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Rational Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Rational Int 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Integer Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Integer Rational 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Integer Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Integer Integer 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Integer Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Integer Double 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Integer Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Integer Int 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric () () Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType () () 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType () () = Bool

Methods

equalTo :: () -> () -> EqCompareType () () Source #

notEqualTo :: () -> () -> EqCompareType () () Source #

HasEqAsymmetric Bool Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Bool Bool 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Char Char Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Char Char 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Double Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Double Integer 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Double Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Double Double 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Double Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Double Int 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Int Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Int Rational 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Int Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Int Integer 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Int Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Int Double 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Int Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Int Int 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric Rational b => HasEqAsymmetric Rational (Complex b) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType Rational (Complex b) 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric Integer b => HasEqAsymmetric Integer (Complex b) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType Integer (Complex b) 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric Double b => HasEqAsymmetric Double (Complex b) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType Double (Complex b) 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric Int b => HasEqAsymmetric Int (Complex b) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType Int (Complex b) 
Instance details

Defined in Numeric.MixedTypes.Complex

(HasEqAsymmetric Rational b, CanBeErrors es, CanTestCertainly (EqCompareType Rational b)) => HasEqAsymmetric Rational (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Rational (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric Integer b, CanBeErrors es, CanTestCertainly (EqCompareType Integer b)) => HasEqAsymmetric Integer (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Integer (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric Bool b, CanBeErrors es, CanTestCertainly (EqCompareType Bool b)) => HasEqAsymmetric Bool (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Bool (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric Double b, CanBeErrors es, CanTestCertainly (EqCompareType Double b)) => HasEqAsymmetric Double (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Double (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric Int b, CanBeErrors es, CanTestCertainly (EqCompareType Int b)) => HasEqAsymmetric Int (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType Int (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric a Rational => HasEqAsymmetric (Complex a) Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType (Complex a) Rational 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric a Integer => HasEqAsymmetric (Complex a) Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType (Complex a) Integer 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric a Double => HasEqAsymmetric (Complex a) Double Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType (Complex a) Double 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric a Int => HasEqAsymmetric (Complex a) Int Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType (Complex a) Int 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric a b => HasEqAsymmetric (Complex a) (Complex b) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type EqCompareType (Complex a) (Complex b) 
Instance details

Defined in Numeric.MixedTypes.Complex

HasEqAsymmetric a b => HasEqAsymmetric (Maybe a) (Maybe b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (Maybe a) (Maybe b) 
Instance details

Defined in Numeric.MixedTypes.Eq

HasEqAsymmetric a b => HasEqAsymmetric [a] [b] Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType [a] [b] 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType [a] [b] = EqCompareType a b

Methods

equalTo :: [a] -> [b] -> EqCompareType [a] [b] Source #

notEqualTo :: [a] -> [b] -> EqCompareType [a] [b] Source #

(HasEqAsymmetric (Maybe Bool) b, CanBeErrors es, CanTestCertainly (EqCompareType (Maybe Bool) b)) => HasEqAsymmetric (Maybe Bool) (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (Maybe Bool) (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a Rational, CanBeErrors es, CanTestCertainly (EqCompareType a Rational)) => HasEqAsymmetric (CollectErrors es a) Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) Rational 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a Integer, CanBeErrors es, CanTestCertainly (EqCompareType a Integer)) => HasEqAsymmetric (CollectErrors es a) Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) Integer 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a Bool, CanBeErrors es, CanTestCertainly (EqCompareType a Bool)) => HasEqAsymmetric (CollectErrors es a) Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) Bool 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a Double, CanBeErrors es, CanTestCertainly (EqCompareType a Double)) => HasEqAsymmetric (CollectErrors es a) Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) Double 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a Int, CanBeErrors es, CanTestCertainly (EqCompareType a Int)) => HasEqAsymmetric (CollectErrors es a) Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) Int 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a (Maybe Bool), CanBeErrors es, CanTestCertainly (EqCompareType a (Maybe Bool))) => HasEqAsymmetric (CollectErrors es a) (Maybe Bool) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) (Maybe Bool) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a b, CanBeErrors es, CanTestCertainly (EqCompareType a b)) => HasEqAsymmetric (CollectErrors es a) (CollectErrors es b) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (CollectErrors es a) (CollectErrors es b) 
Instance details

Defined in Numeric.MixedTypes.Eq

(HasEqAsymmetric a1 b1, HasEqAsymmetric a2 b2, CanAndOrAsymmetric (EqCompareType a1 b1) (EqCompareType a2 b2), IsBool (AndOrType (EqCompareType a1 b1) (EqCompareType a2 b2))) => HasEqAsymmetric (a1, a2) (b1, b2) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (a1, a2) (b1, b2) 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType (a1, a2) (b1, b2) = AndOrType (EqCompareType a1 b1) (EqCompareType a2 b2)

Methods

equalTo :: (a1, a2) -> (b1, b2) -> EqCompareType (a1, a2) (b1, b2) Source #

notEqualTo :: (a1, a2) -> (b1, b2) -> EqCompareType (a1, a2) (b1, b2) Source #

HasEqAsymmetric ((a1, a2), a3) ((b1, b2), b3) => HasEqAsymmetric (a1, a2, a3) (b1, b2, b3) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (a1, a2, a3) (b1, b2, b3) 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType (a1, a2, a3) (b1, b2, b3) = EqCompareType ((a1, a2), a3) ((b1, b2), b3)

Methods

equalTo :: (a1, a2, a3) -> (b1, b2, b3) -> EqCompareType (a1, a2, a3) (b1, b2, b3) Source #

notEqualTo :: (a1, a2, a3) -> (b1, b2, b3) -> EqCompareType (a1, a2, a3) (b1, b2, b3) Source #

HasEqAsymmetric ((a1, a2, a3), a4) ((b1, b2, b3), b4) => HasEqAsymmetric (a1, a2, a3, a4) (b1, b2, b3, b4) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (a1, a2, a3, a4) (b1, b2, b3, b4) 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType (a1, a2, a3, a4) (b1, b2, b3, b4) = EqCompareType ((a1, a2, a3), a4) ((b1, b2, b3), b4)

Methods

equalTo :: (a1, a2, a3, a4) -> (b1, b2, b3, b4) -> EqCompareType (a1, a2, a3, a4) (b1, b2, b3, b4) Source #

notEqualTo :: (a1, a2, a3, a4) -> (b1, b2, b3, b4) -> EqCompareType (a1, a2, a3, a4) (b1, b2, b3, b4) Source #

HasEqAsymmetric ((a1, a2, a3, a4), a5) ((b1, b2, b3, b4), b5) => HasEqAsymmetric (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Associated Types

type EqCompareType (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) 
Instance details

Defined in Numeric.MixedTypes.Eq

type EqCompareType (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) = EqCompareType ((a1, a2, a3, a4), a5) ((b1, b2, b3, b4), b5)

Methods

equalTo :: (a1, a2, a3, a4, a5) -> (b1, b2, b3, b4, b5) -> EqCompareType (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) Source #

notEqualTo :: (a1, a2, a3, a4, a5) -> (b1, b2, b3, b4, b5) -> EqCompareType (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5) Source #

(==) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 Source #

(/=) :: HasEqAsymmetric a b => a -> b -> EqCompareType a b infix 4 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 :: (Arbitrary t1, Arbitrary t2, Arbitrary t3, Show t1, Show t2, Show t3, CanTestCertainly (AndOrType (EqCompareType t1 t2) (EqCompareType t2 t3)), CanTestCertainly (EqCompareType t1 t1), CanTestCertainly (EqCompareType t1 t2), CanTestCertainly (EqCompareType t2 t1), CanTestCertainly (EqCompareType t2 t3), HasEqAsymmetric t1 t1, HasEqAsymmetric t1 t2, HasEqAsymmetric t2 t1, HasEqAsymmetric t2 t3, CanAndOrAsymmetric (EqCompareType t1 t2) (EqCompareType t2 t3)) => T t1 -> T t2 -> T t3 -> Spec Source #

HSpec properties that each implementation of HasEq should satisfy.

specHasEqNotMixed :: (Arbitrary t, Show t, CanTestCertainly (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 CanTestValid t where Source #

Methods

isValid :: t -> Bool Source #

specResultIsValid1 :: (Arbitrary t1, Show t1, CanTestValid t1, CanTestValid t2) => (t1 -> t2) -> String -> T t1 -> Spec Source #

HSpec property checking the validity of unary operations' results.

specResultIsValid2 :: (Arbitrary t1, Show t1, Arbitrary t2, Show t2, CanTestValid t1, CanTestValid t2, CanTestValid t3) => (t1 -> t2 -> t3) -> String -> T t1 -> T t2 -> Spec Source #

HSpec properties that check validity of operations' results.

specResultIsValid1Pre :: (Arbitrary t1, Show t1, CanTestValid t1, CanTestValid t2) => (t1 -> Bool) -> (t1 -> t2) -> String -> T t1 -> Spec Source #

specResultIsValid2Pre :: (Arbitrary t1, Show t1, Arbitrary t2, Show t2, CanTestValid t1, CanTestValid t2, CanTestValid t3) => (t1 -> t2 -> Bool) -> (t1 -> t2 -> t3) -> String -> T t1 -> T t2 -> Spec Source #

class CanTestNaN t where Source #

Minimal complete definition

Nothing

Methods

isNaN :: t -> Bool Source #

default isNaN :: RealFloat t => t -> Bool Source #

Instances

Instances details
CanTestNaN Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

isNaN :: Rational -> Bool Source #

CanTestNaN Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

isNaN :: Integer -> Bool Source #

CanTestNaN Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

isNaN :: Double -> Bool Source #

(CanTestNaN t, CanBeErrors es) => CanTestNaN (CollectErrors es t) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

isNaN :: CollectErrors es t -> Bool Source #

class CanTestFinite t where Source #

Minimal complete definition

Nothing

Methods

isInfinite :: t -> Bool Source #

default isInfinite :: RealFloat t => t -> Bool Source #

isFinite :: t -> Bool Source #

default isFinite :: RealFloat t => t -> Bool Source #

Instances

Instances details
CanTestFinite Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestFinite Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestFinite Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestFinite Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

(CanTestFinite t, CanBeErrors es) => CanTestFinite (CollectErrors es t) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

class CanTestInteger t where Source #

Minimal complete definition

certainlyNotInteger, certainlyIntegerGetIt

Instances

Instances details
CanTestInteger Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestInteger Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestInteger Double Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

CanTestInteger Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

(CanTestInteger t, CanTestZero t) => CanTestInteger (Complex t) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

(CanTestInteger t, CanBeErrors es) => CanTestInteger (CollectErrors es t) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

specCanTestZero :: (CanTestZero t, ConvertibleExactlyWithSample Integer t, Arbitrary t, Show t) => T t -> Spec Source #

HSpec properties that each implementation of CanTestZero should satisfy.

class CanPickNonZero t where Source #

Minimal complete definition

Nothing

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.

default pickNonZero :: (CanTestZero t, Show t) => [(t, s)] -> Maybe (t, s) Source #

Instances

Instances details
CanPickNonZero Rational Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

pickNonZero :: [(Rational, s)] -> Maybe (Rational, s) Source #

CanPickNonZero Integer Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

pickNonZero :: [(Integer, s)] -> Maybe (Integer, s) Source #

CanPickNonZero Int Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

pickNonZero :: [(Int, s)] -> Maybe (Int, s) Source #

(CanPickNonZero a, CanBeErrors es) => CanPickNonZero (CollectErrors es a) Source # 
Instance details

Defined in Numeric.MixedTypes.Eq

Methods

pickNonZero :: [(CollectErrors es a, s)] -> Maybe (CollectErrors es a, s) Source #

specCanPickNonZero :: (CanPickNonZero t, CanTestZero t, ConvertibleExactlyWithSample Integer t, Show t, Arbitrary t) => T t -> Spec Source #

HSpec properties that each implementation of CanPickNonZero should satisfy.