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

Description

 
Synopsis

Square root

class CanSqrt t where Source #

A replacement for Prelude's sqrt. If Floating t, then one can use the default implementation to mirror Prelude's sqrt.

Minimal complete definition

Nothing

Associated Types

type SqrtType t Source #

type SqrtType t = t

Methods

sqrt :: t -> SqrtType t Source #

default sqrt :: (SqrtType t ~ t, Floating t) => t -> SqrtType t Source #

Instances

Instances details
CanSqrt Double Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type SqrtType Double 
Instance details

Defined in Numeric.MixedTypes.Elementary

(CanSqrt a, CanTestPosNeg a, CanMinMaxThis a Integer) => CanSqrt (CN a) Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type SqrtType (CN a) 
Instance details

Defined in Numeric.MixedTypes.Elementary

type SqrtType (CN a) = CN (SqrtType a)

Methods

sqrt :: CN a -> SqrtType (CN a) Source #

Exp

class CanExp t where Source #

A replacement for Prelude's exp. If Floating t, then one can use the default implementation to mirror Prelude's exp.

Minimal complete definition

Nothing

Associated Types

type ExpType t Source #

type ExpType t = t

Methods

exp :: t -> ExpType t Source #

default exp :: (ExpType t ~ t, Floating t) => t -> ExpType t Source #

Instances

Instances details
CanExp Double Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type ExpType Double 
Instance details

Defined in Numeric.MixedTypes.Elementary

(CanExp t, CanSinCos t, CanMulAsymmetric (ExpType t) (SinCosType t)) => CanExp (Complex t) Source # 
Instance details

Defined in Numeric.MixedTypes.Complex

Associated Types

type ExpType (Complex t) 
Instance details

Defined in Numeric.MixedTypes.Complex

Methods

exp :: Complex t -> ExpType (Complex t) Source #

CanExp a => CanExp (CN a) Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type ExpType (CN a) 
Instance details

Defined in Numeric.MixedTypes.Elementary

type ExpType (CN a) = CN (ExpType a)

Methods

exp :: CN a -> ExpType (CN a) Source #

Log

class CanLog t where Source #

A replacement for Prelude's log. If Floating t, then one can use the default implementation to mirror Prelude's log.

Minimal complete definition

Nothing

Associated Types

type LogType t Source #

type LogType t = t

Methods

log :: t -> LogType t Source #

default log :: (LogType t ~ t, Floating t) => t -> LogType t Source #

Instances

Instances details
CanLog Double Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type LogType Double 
Instance details

Defined in Numeric.MixedTypes.Elementary

(CanLog a, CanTestPosNeg a) => CanLog (CN a) Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type LogType (CN a) 
Instance details

Defined in Numeric.MixedTypes.Elementary

type LogType (CN a) = CN (LogType a)

Methods

log :: CN a -> LogType (CN a) Source #

specCanLogReal :: (SubType t t ~ t, SubType t Integer ~ t, SubType Integer t ~ t, AbsType t ~ t, AddType t t ~ t, AddType t Integer ~ t, AddType Integer t ~ t, DivIType t t ~ Integer, MulType t Integer ~ t, MulType Integer t ~ t, DivType t Integer ~ t, ModType t t ~ t, CanSub t t, CanSub t Integer, CanSub Integer t, Arbitrary t, CanAbs t, CanDivIMod t t, CanDiv t Integer, CanDiv Integer t, CanMulAsymmetric t t, CanMulAsymmetric t Integer, CanMulAsymmetric Integer t, CanAddAsymmetric t t, CanAddAsymmetric t Integer, CanAddAsymmetric (LogType t) (LogType t), CanAddAsymmetric Integer t, CanExp t, HasOrderAsymmetric t t, HasOrderAsymmetric t Integer, HasOrderAsymmetric (DivType Integer t) Integer, HasOrderAsymmetric (MulType t t) Integer, HasOrderAsymmetric (ExpType t) Integer, HasEqAsymmetric (LogType (DivType Integer t)) (NegType (LogType t)), HasEqAsymmetric (LogType (MulType t t)) (AddType (LogType t) (LogType t)), HasEqAsymmetric (LogType (ExpType t)) t, CanTestCertainly (OrderCompareType t t), CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType (DivType Integer t) Integer), CanTestCertainly (OrderCompareType (MulType t t) Integer), CanTestCertainly (OrderCompareType (ExpType t) Integer), CanTestCertainly (EqCompareType (LogType (DivType Integer t)) (NegType (LogType t))), CanTestCertainly (EqCompareType (LogType (MulType t t)) (AddType (LogType t) (LogType t))), CanTestCertainly (EqCompareType (LogType (ExpType t)) t), Show t, Show (AddType (LogType t) (LogType t)), Show (NegType (LogType t)), Show (LogType (DivType Integer t)), Show (LogType (MulType t t)), Show (LogType (ExpType t)), CanLog t, CanLog (DivType Integer t), CanLog (MulType t t), CanLog (ExpType t), ConvertibleExactlyWithSample Integer t, CanNeg (LogType t)) => T t -> Spec Source #

HSpec properties that each implementation of CanLog should satisfy.

powUsingExpLog :: (CanLogSameType t, CanExpSameType t, CanTestInteger t, CanTestZero t) => t -> (t -> t -> t) -> (t -> t) -> t -> t -> t Source #

Sine and cosine

class CanSinCos t where Source #

A replacement for Prelude's cos and sin. If Floating t, then one can use the default implementation to mirror Prelude's sin, cos.

Minimal complete definition

Nothing

Associated Types

type SinCosType t Source #

type SinCosType t = t

Methods

cos :: t -> SinCosType t Source #

default cos :: (SinCosType t ~ t, Floating t) => t -> SinCosType t Source #

sin :: t -> SinCosType t Source #

default sin :: (SinCosType t ~ t, Floating t) => t -> SinCosType t Source #

Instances

Instances details
CanSinCos Double Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type SinCosType Double 
Instance details

Defined in Numeric.MixedTypes.Elementary

CanSinCos a => CanSinCos (CN a) Source # 
Instance details

Defined in Numeric.MixedTypes.Elementary

Associated Types

type SinCosType (CN a) 
Instance details

Defined in Numeric.MixedTypes.Elementary

type SinCosType (CN a) = CN (SinCosType a)

Methods

cos :: CN a -> SinCosType (CN a) Source #

sin :: CN a -> SinCosType (CN a) Source #

specCanSinCosReal :: (Arbitrary t, CanPow (SinCosType t) Integer, CanSinCos t, CanSinCos (SubType t t), CanSub t t, CanSub (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t)), CanMulAsymmetric (SinCosType t) (SinCosType t), HasEqAsymmetric (AddType (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer)) Integer, HasEqAsymmetric (SinCosType (SubType t t)) (SubType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t))), HasEqAsymmetric (SinCosType (SubType t t)) (AddType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t))), CanAddAsymmetric (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer), CanAddAsymmetric (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t)), HasOrderAsymmetric t (DivType (SinCosType t) (SinCosType t)), HasOrderAsymmetric t Rational, HasOrderAsymmetric t Integer, HasOrderAsymmetric (SinCosType t) t, HasOrderAsymmetric (SinCosType t) Integer, HasOrderAsymmetric Integer (SinCosType t), CanTestCertainly (EqCompareType (AddType (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer)) Integer), CanTestCertainly (EqCompareType (SinCosType (SubType t t)) (SubType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t)))), CanTestCertainly (EqCompareType (SinCosType (SubType t t)) (AddType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t)))), CanTestCertainly (OrderCompareType t (DivType (SinCosType t) (SinCosType t))), CanTestCertainly (OrderCompareType t Rational), CanTestCertainly (OrderCompareType t Integer), CanTestCertainly (OrderCompareType (SinCosType t) t), CanTestCertainly (OrderCompareType (SinCosType t) Integer), CanTestCertainly (OrderCompareType Integer (SinCosType t)), Show t, Show (SubType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t))), Show (AddType (PowType (SinCosType t) Integer) (PowType (SinCosType t) Integer)), Show (AddType (MulType (SinCosType t) (SinCosType t)) (MulType (SinCosType t) (SinCosType t))), Show (DivType (SinCosType t) (SinCosType t)), Show (SinCosType t), Show (SinCosType (SubType t t)), CanDiv (SinCosType t) (SinCosType t)) => T t -> Spec Source #

HSpec properties that each implementation of CanSinCos should satisfy.

Derived partially from http://math.stackexchange.com/questions/1303044/axiomatic-definition-of-sin-and-cos

approxPi :: Floating t => t Source #

Approximate pi, synonym for Prelude's pi.

We do not define (exect) pi in this package as we have no type that can represent it exactly.