mixed-types-num-0.2: Alternative Prelude with numeric and logic expressions typed bottom-up

Copyright(c) Michal Konecny
LicenseBSD3
Maintainermikkonecny@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Numeric.MixedTypes.Ring

Contents

Description

 

Synopsis

Ring

Multiplication

type CanMul t1 t2 = (CanMulAsymmetric t1 t2, CanMulAsymmetric t2 t1, MulType t1 t2 ~ MulType t2 t1) Source #

class CanMulAsymmetric t1 t2 where Source #

A replacement for Prelude's *. If t1 = t2 and Num t1, then one can use the default implementation to mirror Prelude's *.

Associated Types

type MulType t1 t2 Source #

Methods

mul :: t1 -> t2 -> MulType t1 t2 Source #

mul :: (MulType t1 t2 ~ t1, t1 ~ t2, Num t1) => t1 -> t1 -> t1 Source #

Instances

CanMulAsymmetric Double Double Source # 

Associated Types

type MulType Double Double :: * Source #

CanMulAsymmetric Double Int Source # 

Associated Types

type MulType Double Int :: * Source #

CanMulAsymmetric Double Integer Source # 

Associated Types

type MulType Double Integer :: * Source #

CanMulAsymmetric Double Rational Source # 

Associated Types

type MulType Double Rational :: * Source #

CanMulAsymmetric Int Double Source # 

Associated Types

type MulType Int Double :: * Source #

CanMulAsymmetric Int Int Source # 

Associated Types

type MulType Int Int :: * Source #

Methods

mul :: Int -> Int -> MulType Int Int Source #

CanMulAsymmetric Int Integer Source # 

Associated Types

type MulType Int Integer :: * Source #

CanMulAsymmetric Int Rational Source # 

Associated Types

type MulType Int Rational :: * Source #

CanMulAsymmetric Integer Double Source # 

Associated Types

type MulType Integer Double :: * Source #

CanMulAsymmetric Integer Int Source # 

Associated Types

type MulType Integer Int :: * Source #

CanMulAsymmetric Integer Integer Source # 

Associated Types

type MulType Integer Integer :: * Source #

CanMulAsymmetric Integer Rational Source # 

Associated Types

type MulType Integer Rational :: * Source #

CanMulAsymmetric Rational Double Source # 

Associated Types

type MulType Rational Double :: * Source #

CanMulAsymmetric Rational Int Source # 

Associated Types

type MulType Rational Int :: * Source #

CanMulAsymmetric Rational Integer Source # 

Associated Types

type MulType Rational Integer :: * Source #

CanMulAsymmetric Rational Rational Source # 
(CanMulAsymmetric Double b0, CanEnsureCE es0 (MulType Double b0), SuitableForCE es0) => CanMulAsymmetric Double (CollectErrors es0 b0) Source # 

Associated Types

type MulType Double (CollectErrors es0 b0) :: * Source #

Methods

mul :: Double -> CollectErrors es0 b0 -> MulType Double (CollectErrors es0 b0) Source #

(CanMulAsymmetric Int b0, CanEnsureCE es0 (MulType Int b0), SuitableForCE es0) => CanMulAsymmetric Int (CollectErrors es0 b0) Source # 

Associated Types

type MulType Int (CollectErrors es0 b0) :: * Source #

Methods

mul :: Int -> CollectErrors es0 b0 -> MulType Int (CollectErrors es0 b0) Source #

(CanMulAsymmetric Integer b0, CanEnsureCE es0 (MulType Integer b0), SuitableForCE es0) => CanMulAsymmetric Integer (CollectErrors es0 b0) Source # 

Associated Types

type MulType Integer (CollectErrors es0 b0) :: * Source #

Methods

mul :: Integer -> CollectErrors es0 b0 -> MulType Integer (CollectErrors es0 b0) Source #

(CanMulAsymmetric Rational b0, CanEnsureCE es0 (MulType Rational b0), SuitableForCE es0) => CanMulAsymmetric Rational (CollectErrors es0 b0) Source # 

Associated Types

type MulType Rational (CollectErrors es0 b0) :: * Source #

CanMulAsymmetric a b => CanMulAsymmetric [a] [b] Source # 

Associated Types

type MulType [a] [b] :: * Source #

Methods

mul :: [a] -> [b] -> MulType [a] [b] Source #

CanMulAsymmetric a b => CanMulAsymmetric (Maybe a) (Maybe b) Source # 

Associated Types

type MulType (Maybe a) (Maybe b) :: * Source #

Methods

mul :: Maybe a -> Maybe b -> MulType (Maybe a) (Maybe b) Source #

(CanMulAsymmetric a0 Double, CanEnsureCE es0 (MulType a0 Double), SuitableForCE es0) => CanMulAsymmetric (CollectErrors es0 a0) Double Source # 

Associated Types

type MulType (CollectErrors es0 a0) Double :: * Source #

Methods

mul :: CollectErrors es0 a0 -> Double -> MulType (CollectErrors es0 a0) Double Source #

(CanMulAsymmetric a0 Rational, CanEnsureCE es0 (MulType a0 Rational), SuitableForCE es0) => CanMulAsymmetric (CollectErrors es0 a0) Rational Source # 

Associated Types

type MulType (CollectErrors es0 a0) Rational :: * Source #

(CanMulAsymmetric a0 Int, CanEnsureCE es0 (MulType a0 Int), SuitableForCE es0) => CanMulAsymmetric (CollectErrors es0 a0) Int Source # 

Associated Types

type MulType (CollectErrors es0 a0) Int :: * Source #

Methods

mul :: CollectErrors es0 a0 -> Int -> MulType (CollectErrors es0 a0) Int Source #

(CanMulAsymmetric a0 Integer, CanEnsureCE es0 (MulType a0 Integer), SuitableForCE es0) => CanMulAsymmetric (CollectErrors es0 a0) Integer Source # 

Associated Types

type MulType (CollectErrors es0 a0) Integer :: * Source #

Methods

mul :: CollectErrors es0 a0 -> Integer -> MulType (CollectErrors es0 a0) Integer Source #

(CanMulAsymmetric a b, CanEnsureCE es (MulType a b), SuitableForCE es) => CanMulAsymmetric (CollectErrors es a) (CollectErrors es b) Source # 

Associated Types

type MulType (CollectErrors es a) (CollectErrors es b) :: * Source #

Methods

mul :: CollectErrors es a -> CollectErrors es b -> MulType (CollectErrors es a) (CollectErrors es b) Source #

type CanMulBy t1 t2 = (CanMul t1 t2, MulType t1 t2 ~ t1) Source #

(*) :: CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2 infixl 7 Source #

Tests

specCanMul :: (CanMulX t1 t2, CanMulX t1 t3, CanMulX t2 t3, CanMulX t1 (MulType t2 t3), CanMulX (MulType t1 t2) t3, HasEqCertainly (MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3), CanAdd t2 t3, CanMulX t1 (AddType t2 t3), CanAddX (MulType t1 t2) (MulType t1 t3), HasEqCertainly (MulType t1 (AddType t2 t3)) (AddType (MulType t1 t2) (MulType t1 t3)), ConvertibleExactly Integer t2) => T t1 -> T t2 -> T t3 -> Spec Source #

HSpec properties that each implementation of CanMul should satisfy.

specCanMulNotMixed :: (CanMulX t t, CanMulX t (MulType t t), HasEqCertainly (MulType (MulType t t) t) (MulType t (MulType t t)), CanAdd t t, CanMulX t (AddType t t), CanAddX (MulType t t) (MulType t t), HasEqCertainly (MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)), ConvertibleExactly Integer t) => T t -> Spec Source #

HSpec properties that each implementation of CanMul should satisfy.

specCanMulSameType :: (ConvertibleExactly Integer t, Show t, HasEqCertainly t t, CanMulSameType t) => T t -> Spec Source #

HSpec properties that each implementation of CanMulSameType should satisfy.

type CanMulX t1 t2 = (CanMul t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2, Show (MulType t1 t2), HasEqCertainly t1 (MulType t1 t2), HasEqCertainly t2 (MulType t1 t2), HasEqCertainly (MulType t1 t2) (MulType t1 t2), HasOrderCertainly t1 (MulType t1 t2), HasOrderCertainly t2 (MulType t1 t2), HasOrderCertainly (MulType t1 t2) (MulType t1 t2)) Source #

Compound type constraint useful for test definition.

Exponentiation

class CanPow t1 t2 where Source #

A replacement for Prelude's binary ^ and ^^. If Num t1 and Integral t2, then one can use the default implementation to mirror Prelude's ^.

Minimal complete definition

pow

Associated Types

type PowType t1 t2 Source #

Methods

pow :: t1 -> t2 -> PowType t1 t2 Source #

Instances

CanPow Double Int Source # 

Associated Types

type PowType Double Int :: * Source #

CanPow Double Integer Source # 

Associated Types

type PowType Double Integer :: * Source #

CanPow Int Int Source # 

Associated Types

type PowType Int Int :: * Source #

Methods

pow :: Int -> Int -> PowType Int Int Source #

CanPow Int Integer Source # 

Associated Types

type PowType Int Integer :: * Source #

CanPow Integer Int Source # 

Associated Types

type PowType Integer Int :: * Source #

CanPow Integer Integer Source # 

Associated Types

type PowType Integer Integer :: * Source #

CanPow Rational Int Source # 

Associated Types

type PowType Rational Int :: * Source #

CanPow Rational Integer Source # 

Associated Types

type PowType Rational Integer :: * Source #

(CanPow Double b0, CanEnsureCE es0 (PowType Double b0), SuitableForCE es0) => CanPow Double (CollectErrors es0 b0) Source # 

Associated Types

type PowType Double (CollectErrors es0 b0) :: * Source #

Methods

pow :: Double -> CollectErrors es0 b0 -> PowType Double (CollectErrors es0 b0) Source #

(CanPow Int b0, CanEnsureCE es0 (PowType Int b0), SuitableForCE es0) => CanPow Int (CollectErrors es0 b0) Source # 

Associated Types

type PowType Int (CollectErrors es0 b0) :: * Source #

Methods

pow :: Int -> CollectErrors es0 b0 -> PowType Int (CollectErrors es0 b0) Source #

(CanPow Integer b0, CanEnsureCE es0 (PowType Integer b0), SuitableForCE es0) => CanPow Integer (CollectErrors es0 b0) Source # 

Associated Types

type PowType Integer (CollectErrors es0 b0) :: * Source #

Methods

pow :: Integer -> CollectErrors es0 b0 -> PowType Integer (CollectErrors es0 b0) Source #

(CanPow Rational b0, CanEnsureCE es0 (PowType Rational b0), SuitableForCE es0) => CanPow Rational (CollectErrors es0 b0) Source # 

Associated Types

type PowType Rational (CollectErrors es0 b0) :: * Source #

CanPow a b => CanPow (Maybe a) (Maybe b) Source # 

Associated Types

type PowType (Maybe a) (Maybe b) :: * Source #

Methods

pow :: Maybe a -> Maybe b -> PowType (Maybe a) (Maybe b) Source #

(CanPow a0 Double, CanEnsureCE es0 (PowType a0 Double), SuitableForCE es0) => CanPow (CollectErrors es0 a0) Double Source # 

Associated Types

type PowType (CollectErrors es0 a0) Double :: * Source #

Methods

pow :: CollectErrors es0 a0 -> Double -> PowType (CollectErrors es0 a0) Double Source #

(CanPow a0 Rational, CanEnsureCE es0 (PowType a0 Rational), SuitableForCE es0) => CanPow (CollectErrors es0 a0) Rational Source # 

Associated Types

type PowType (CollectErrors es0 a0) Rational :: * Source #

(CanPow a0 Int, CanEnsureCE es0 (PowType a0 Int), SuitableForCE es0) => CanPow (CollectErrors es0 a0) Int Source # 

Associated Types

type PowType (CollectErrors es0 a0) Int :: * Source #

Methods

pow :: CollectErrors es0 a0 -> Int -> PowType (CollectErrors es0 a0) Int Source #

(CanPow a0 Integer, CanEnsureCE es0 (PowType a0 Integer), SuitableForCE es0) => CanPow (CollectErrors es0 a0) Integer Source # 

Associated Types

type PowType (CollectErrors es0 a0) Integer :: * Source #

Methods

pow :: CollectErrors es0 a0 -> Integer -> PowType (CollectErrors es0 a0) Integer Source #

(CanPow a b, CanEnsureCE es (PowType a b), SuitableForCE es) => CanPow (CollectErrors es a) (CollectErrors es b) Source # 

Associated Types

type PowType (CollectErrors es a) (CollectErrors es b) :: * Source #

Methods

pow :: CollectErrors es a -> CollectErrors es b -> PowType (CollectErrors es a) (CollectErrors es b) Source #

type CanPowBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ t1) Source #

type CanPowCNBy t1 t2 = (CanPow t1 t2, PowType t1 t2 ~ EnsureCN t1) Source #

(^) :: CanPow t1 t2 => t1 -> t2 -> PowType t1 t2 infixl 8 Source #

(^!) :: (CanPow t1 t2, Show (PowType t1 t2), CanEnsureCN (PowType t1 t2)) => t1 -> t2 -> EnsureNoCN (PowType t1 t2) infixl 8 Source #

Like ^ but throwing an exception if the power is undefined.

Tests

specCanPow :: (CanPowX t1 t2, HasEqCertainly t1 (PowType t1 t2), ConvertibleExactly Integer t1, ConvertibleExactly Integer t2, CanTestPosNeg t2, CanAdd t2 Integer, CanMulX t1 (PowType t1 t2), CanPowX t1 (AddType t2 Integer), HasEqCertainly (MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))) => T t1 -> T t2 -> Spec Source #

HSpec properties that each implementation of CanPow should satisfy.

type CanPowX t1 t2 = (CanPow t1 t2, Show t1, Arbitrary t1, Show t2, Arbitrary t2, Show (PowType t1 t2)) Source #

Compound type constraint useful for test definition.