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.Bool

Description

 
Synopsis

Documentation

type IsBool t = (HasBools t, CanNegSameType t, CanAndOrSameType t) Source #

A type constraint synonym that stipulates that the type behaves very much like Bool, except it does not necessarily satisfy the law of excluded middle, which means that the type can contain a "do-not-know" value or an error.

Examples: Bool, Kleenean, CollectErrors Bool

specIsBool :: (IsBool t, CanTestCertainly t, Show t, Serial IO t) => T t -> Spec Source #

HSpec properties that each implementation of IsBool should satisfy.

Conversion to/from Bool

class HasBools t => CanTestCertainly t where Source #

Tests for truth or falsity. Beware, when isCertainlyTrue returns False, it does not mean that the proposition is false. It usually means that we failed to prove the proposition.

specCanTestCertainly :: CanTestCertainly t => T t -> Spec Source #

HSpec properties that each implementation of CanTestCertainly should satisfy.

type CanTestCertainlyX t = (CanTestCertainly t, Show t, Serial IO t) Source #

Compound type constraint useful for test definition.

stronglyImplies :: (CanTestCertainly t1, CanTestCertainly t2) => t1 -> t2 -> Bool Source #

If l is certainly True, then r is also certainly True.

weaklyImplies :: (CanTestCertainly t1, CanTestCertainly t2) => t1 -> t2 -> Bool Source #

If l is certainly True, then r is not certainly False.

Negation

class CanNeg t where Source #

This is negation is both the numeric negation as well as the Boolean negation. Example of non-standard Boolean negation:

 negate (Just True) = Just False
 

Associated Types

type NegType t Source #

type NegType t = t

Methods

negate :: t -> NegType t Source #

Instances

Instances details
CanNeg Rational Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Rational 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

CanNeg Integer Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Integer 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

CanNeg Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type NegType Bool 
Instance details

Defined in Numeric.MixedTypes.Bool

CanNeg Double Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Double 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

CanNeg Int Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Int 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

type NegType Int = Int

Methods

negate :: Int -> NegType Int Source #

CanNeg t => CanNeg (Complex t) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type NegType (Complex t) 
Instance details

Defined in Numeric.MixedTypes.Complex

Methods

negate :: Complex t -> NegType (Complex t) Source #

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

Defined in Numeric.MixedTypes.Bool

Associated Types

type NegType (CollectErrors es t) 
Instance details

Defined in Numeric.MixedTypes.Bool

not :: CanNeg t => t -> NegType t Source #

A synonym of negate.

Tests

specCanNegBool :: (CanTestCertainly t, CanTestCertainly (NegType t), CanTestCertainly (NegType (NegType t)), Serial IO t, Show t, Show (NegType (NegType t)), CanNeg t, CanNeg (NegType t)) => T t -> Spec Source #

HSpec properties that each Boolean implementation of CanNeg should satisfy.

And and or

type CanAndOr t1 t2 = (CanAndOrAsymmetric t1 t2, CanAndOrAsymmetric t2 t1, AndOrType t1 t2 ~ AndOrType t2 t1) Source #

class CanAndOrAsymmetric t1 t2 where Source #

Binary logical and and or for generalised Booleans. For example:

 (Just True) && False = Just False
 (Just (Just True)) || False = (Just (Just True))
 

Associated Types

type AndOrType t1 t2 Source #

Methods

and2 :: t1 -> t2 -> AndOrType t1 t2 Source #

or2 :: t1 -> t2 -> AndOrType t1 t2 Source #

Instances

Instances details
CanAndOrAsymmetric Bool Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type AndOrType Bool Bool 
Instance details

Defined in Numeric.MixedTypes.Bool

(CanAndOrAsymmetric Bool t2, CanBeErrors es) => CanAndOrAsymmetric Bool (CollectErrors es t2) Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type AndOrType Bool (CollectErrors es t2) 
Instance details

Defined in Numeric.MixedTypes.Bool

(CanAndOrAsymmetric t1 Bool, CanBeErrors es) => CanAndOrAsymmetric (CollectErrors es t1) Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type AndOrType (CollectErrors es t1) Bool 
Instance details

Defined in Numeric.MixedTypes.Bool

(CanAndOrAsymmetric t1 t2, CanBeErrors es, HasBools t2, CanTestCertainly t1) => CanAndOrAsymmetric (CollectErrors es t1) (CollectErrors es t2) Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type AndOrType (CollectErrors es t1) (CollectErrors es t2) 
Instance details

Defined in Numeric.MixedTypes.Bool

type AndOrType (CollectErrors es t1) (CollectErrors es t2) = CollectErrors es (AndOrType t1 t2)

(&&) :: CanAndOrAsymmetric a b => a -> b -> AndOrType a b infixr 3 Source #

A synonym of and2.

(||) :: CanAndOrAsymmetric a b => a -> b -> AndOrType a b infixr 2 Source #

A synonym of or2.

type CanAndOrWith t1 t2 = (CanAndOr t1 t2, AndOrType t1 t2 ~ t1) Source #

Tests

specCanAndOr :: (Serial IO t1, Serial IO t2, Serial IO t3, Show t1, Show t2, Show t3, Show (AndOrType t2 t1), Show (AndOrType t1 t1), Show (AndOrType t1 t2), Show (AndOrType t1 (AndOrType t2 t3)), Show (AndOrType (AndOrType t1 t2) t3), Show (AndOrType (AndOrType t1 t2) (AndOrType t1 t3)), Show (AndOrType (NegType t1) (NegType t2)), Show (NegType (AndOrType t1 t2)), CanTestCertainly t1, CanTestCertainly (AndOrType t2 t1), CanTestCertainly (AndOrType t1 t1), CanTestCertainly (AndOrType t1 t2), CanTestCertainly (AndOrType t1 (AndOrType t2 t3)), CanTestCertainly (AndOrType (AndOrType t1 t2) t3), CanTestCertainly (AndOrType (AndOrType t1 t2) (AndOrType t1 t3)), CanTestCertainly (AndOrType (NegType t1) (NegType t2)), CanTestCertainly (NegType (AndOrType t1 t2)), CanAndOrAsymmetric t2 t1, CanAndOrAsymmetric t2 t3, CanAndOrAsymmetric t1 t1, CanAndOrAsymmetric t1 t2, CanAndOrAsymmetric t1 t3, CanAndOrAsymmetric t1 (AndOrType t2 t3), CanAndOrAsymmetric (AndOrType t1 t2) t3, CanAndOrAsymmetric (AndOrType t1 t2) (AndOrType t1 t3), CanAndOrAsymmetric (NegType t1) (NegType t2), CanNeg t1, CanNeg t2, CanNeg (AndOrType t1 t2)) => T t1 -> T t2 -> T t3 -> Spec Source #

HSpec properties that each implementation of CanAndOr should satisfy.

Orphan instances