mixed-types-num-0.5.4.0: Alternative Prelude with numeric and logic expressions typed bottom-up
Copyright(c) Michal Konecny
LicenseBSD3
Maintainermikkonecny@gmail.com
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 Bool Source # 
Instance details

Defined in Numeric.MixedTypes.Bool

Associated Types

type NegType Bool Source #

CanNeg Double Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Double Source #

CanNeg Int Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Int Source #

Methods

negate :: Int -> NegType Int Source #

CanNeg Integer Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Integer Source #

CanNeg Rational Source # 
Instance details

Defined in Numeric.MixedTypes.MinMaxAbs

Associated Types

type NegType Rational Source #

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

Defined in Numeric.MixedTypes.Complex

Associated Types

type NegType (Complex t) Source #

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) Source #

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

A synonym of negate.

type CanNegSameType t = (CanNeg t, NegType t ~ t) Source #

Tests

specCanNegBool :: _ => 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 Source #

(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) Source #

(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 Source #

(CanAndOrAsymmetric t1 t2, CanBeErrors es) => 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) Source #

(&&) :: 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 :: _ => T t1 -> T t2 -> T t3 -> Spec Source #

HSpec properties that each implementation of CanAndOr should satisfy.

specCanAndOrNotMixed :: _ => T t -> Spec Source #

HSpec properties that each implementation of CanAndOr should satisfy.

Orphan instances