{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module AERN2.MP.Dyadic
(
Dyadic, HasDyadics
, CanBeDyadic, dyadic
, specDyadic, tDyadic
)
where
#ifdef DEBUG
import Debug.Trace (trace)
#define maybeTrace trace
#define maybeTraceIO putStrLn
#else
#define maybeTrace (\ (_ :: String) t -> t)
#define maybeTraceIO (\ (_ :: String) -> return ())
#endif
import MixedTypesNumPrelude
import qualified Prelude as P
import Control.CollectErrors (CollectErrors(..), CanBeErrors)
import qualified Control.CollectErrors as CE
import Text.Printf
import Text.Regex.TDFA
import Data.Typeable
import Test.Hspec
import Test.QuickCheck
import Data.Ratio (denominator, numerator)
import Math.NumberTheory.Logarithms (integerLog2)
import AERN2.Norm
import AERN2.MP.Precision
import AERN2.MP.Accuracy
import AERN2.MP.Float
newtype Dyadic = Dyadic { Dyadic -> MPFloat
dyadicMPFloat :: MPFloat }
deriving (Dyadic -> Dyadic -> Bool
(Dyadic -> Dyadic -> Bool)
-> (Dyadic -> Dyadic -> Bool) -> Eq Dyadic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Dyadic -> Dyadic -> Bool
$c/= :: Dyadic -> Dyadic -> Bool
== :: Dyadic -> Dyadic -> Bool
$c== :: Dyadic -> Dyadic -> Bool
P.Eq, Eq Dyadic
Eq Dyadic
-> (Dyadic -> Dyadic -> Ordering)
-> (Dyadic -> Dyadic -> Bool)
-> (Dyadic -> Dyadic -> Bool)
-> (Dyadic -> Dyadic -> Bool)
-> (Dyadic -> Dyadic -> Bool)
-> (Dyadic -> Dyadic -> Dyadic)
-> (Dyadic -> Dyadic -> Dyadic)
-> Ord Dyadic
Dyadic -> Dyadic -> Bool
Dyadic -> Dyadic -> Ordering
Dyadic -> Dyadic -> Dyadic
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Dyadic -> Dyadic -> Dyadic
$cmin :: Dyadic -> Dyadic -> Dyadic
max :: Dyadic -> Dyadic -> Dyadic
$cmax :: Dyadic -> Dyadic -> Dyadic
>= :: Dyadic -> Dyadic -> Bool
$c>= :: Dyadic -> Dyadic -> Bool
> :: Dyadic -> Dyadic -> Bool
$c> :: Dyadic -> Dyadic -> Bool
<= :: Dyadic -> Dyadic -> Bool
$c<= :: Dyadic -> Dyadic -> Bool
< :: Dyadic -> Dyadic -> Bool
$c< :: Dyadic -> Dyadic -> Bool
compare :: Dyadic -> Dyadic -> Ordering
$ccompare :: Dyadic -> Dyadic -> Ordering
$cp1Ord :: Eq Dyadic
P.Ord, Dyadic -> (RoundType Dyadic, Dyadic)
Dyadic -> RoundType Dyadic
(Dyadic -> (RoundType Dyadic, Dyadic))
-> (Dyadic -> RoundType Dyadic)
-> (Dyadic -> RoundType Dyadic)
-> (Dyadic -> RoundType Dyadic)
-> (Dyadic -> RoundType Dyadic)
-> CanRound Dyadic
forall t.
(t -> (RoundType t, t))
-> (t -> RoundType t)
-> (t -> RoundType t)
-> (t -> RoundType t)
-> (t -> RoundType t)
-> CanRound t
floor :: Dyadic -> RoundType Dyadic
$cfloor :: Dyadic -> RoundType Dyadic
ceiling :: Dyadic -> RoundType Dyadic
$cceiling :: Dyadic -> RoundType Dyadic
round :: Dyadic -> RoundType Dyadic
$cround :: Dyadic -> RoundType Dyadic
truncate :: Dyadic -> RoundType Dyadic
$ctruncate :: Dyadic -> RoundType Dyadic
properFraction :: Dyadic -> (RoundType Dyadic, Dyadic)
$cproperFraction :: Dyadic -> (RoundType Dyadic, Dyadic)
CanRound, Dyadic -> Precision
(Dyadic -> Precision) -> HasPrecision Dyadic
forall t. (t -> Precision) -> HasPrecision t
getPrecision :: Dyadic -> Precision
$cgetPrecision :: Dyadic -> Precision
HasPrecision, Dyadic -> NormLog
(Dyadic -> NormLog) -> HasNorm Dyadic
forall a. (a -> NormLog) -> HasNorm a
getNormLog :: Dyadic -> NormLog
$cgetNormLog :: Dyadic -> NormLog
HasNorm, Typeable)
instance Ring Dyadic
instance Ring (CN Dyadic)
instance OrderedRing Dyadic
instance OrderedRing (CN Dyadic)
instance OrderedCertainlyRing Dyadic
instance OrderedCertainlyRing (CN Dyadic)
instance HasAccuracy Dyadic where getAccuracy :: Dyadic -> Accuracy
getAccuracy Dyadic
_ = Accuracy
Exact
instance CanGiveUpIfVeryInaccurate Dyadic
instance Show Dyadic where
show :: Dyadic -> String
show (Dyadic MPFloat
x)
| Integer
e Integer -> Integer -> EqCompareType Integer Integer
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Integer
0 = String -> Integer -> String
forall r. PrintfType r => String -> r
printf String
"dyadic (%d)" Integer
n
| Integer
e Integer -> Integer -> OrderCompareType Integer Integer
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
> Integer
0 = String -> Integer -> Integer -> String
forall r. PrintfType r => String -> r
printf String
"dyadic (%d*0.5^%d)" Integer
n Integer
e
| Bool
otherwise = ShowS
forall a. HasCallStack => String -> a
error String
"in show Dyadic"
where
xR :: Rational
xR = MPFloat -> Rational
forall t. CanBeRational t => t -> Rational
rational MPFloat
x
NormBits Integer
e = Integer -> NormLog
forall a. HasNorm a => a -> NormLog
getNormLog (Rational -> Integer
forall a. Ratio a -> a
denominator Rational
xR)
n :: Integer
n = Rational -> Integer
forall a. Ratio a -> a
numerator Rational
xR
instance Read Dyadic where
readsPrec :: Int -> ReadS Dyadic
readsPrec Int
_pr String
dyadicS =
[(Dyadic, String)] -> [(Dyadic, String)]
tryInt ([(Dyadic, String)] -> [(Dyadic, String)])
-> [(Dyadic, String)] -> [(Dyadic, String)]
forall a b. (a -> b) -> a -> b
$ [(Dyadic, String)] -> [(Dyadic, String)]
tryWithExp []
where
tryInt :: [(Dyadic, String)] -> [(Dyadic, String)]
tryInt [(Dyadic, String)]
tryNext =
case [String]
groups of
[String
nS] ->
case ReadS Integer
forall a. Read a => ReadS a
reads String
nS of
[(Integer
n,String
"")] -> [(Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic (Integer
n :: Integer), String
afterS)]
[(Integer, String)]
_ -> [(Dyadic, String)]
tryNext
[String]
_ -> [(Dyadic, String)]
tryNext
where
(String
_,String
_,String
afterS,[String]
groups) =
String
dyadicS String -> String -> (String, String, String, [String])
forall source source1 target.
(RegexMaker Regex CompOption ExecOption source,
RegexContext Regex source1 target) =>
source1 -> source -> target
=~ String
"\\`dyadic \\(([-0-9]*)\\)"
:: (String, String, String, [String])
tryWithExp :: [(Dyadic, String)] -> [(Dyadic, String)]
tryWithExp [(Dyadic, String)]
tryNext =
case [String]
groups of
[String
nS,String
eS] ->
case (ReadS Integer
forall a. Read a => ReadS a
reads String
nS, ReadS Integer
forall a. Read a => ReadS a
reads String
eS) of
([(Integer
n,String
"")],[(Integer
e,String
"")]) ->
[((Integer
n :: Integer)Integer -> Dyadic -> MulType Integer Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
*(Rational -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Rational
0.5)Dyadic -> Integer -> PowType Dyadic Integer
forall t1 t2. CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
^(Integer
e :: Integer), String
afterS)]
([(Integer, String)], [(Integer, String)])
_ -> [(Dyadic, String)]
tryNext
[String]
_ -> [(Dyadic, String)]
tryNext
where
(String
_,String
_,String
afterS,[String]
groups) =
String
dyadicS String -> String -> (String, String, String, [String])
forall source source1 target.
(RegexMaker Regex CompOption ExecOption source,
RegexContext Regex source1 target) =>
source1 -> source -> target
=~ String
"\\`dyadic \\(([-0-9]*)\\*0.5\\^([0-9]*)\\)"
:: (String, String, String, [String])
type HasDyadics t = ConvertibleExactly Dyadic t
instance ConvertibleExactly Dyadic Dyadic where
safeConvertExactly :: Dyadic -> ConvertResult Dyadic
safeConvertExactly = Dyadic -> ConvertResult Dyadic
forall a b. b -> Either a b
Right
instance ConvertibleExactly Dyadic MPFloat where
safeConvertExactly :: Dyadic -> ConvertResult MPFloat
safeConvertExactly = MPFloat -> ConvertResult MPFloat
forall a b. b -> Either a b
Right (MPFloat -> ConvertResult MPFloat)
-> (Dyadic -> MPFloat) -> Dyadic -> ConvertResult MPFloat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> MPFloat
dyadicMPFloat
instance ConvertibleExactly Dyadic Rational where
safeConvertExactly :: Dyadic -> ConvertResult Rational
safeConvertExactly = MPFloat -> ConvertResult Rational
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> ConvertResult t2
safeConvertExactly (MPFloat -> ConvertResult Rational)
-> (Dyadic -> MPFloat) -> Dyadic -> ConvertResult Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> MPFloat
dyadicMPFloat
type CanBeDyadic t = ConvertibleExactly t Dyadic
dyadic :: (CanBeDyadic t) => t -> Dyadic
dyadic :: t -> Dyadic
dyadic = t -> Dyadic
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> t2
convertExactly
instance ConvertibleExactly MPFloat Dyadic where
safeConvertExactly :: MPFloat -> ConvertResult Dyadic
safeConvertExactly = Dyadic -> ConvertResult Dyadic
forall a b. b -> Either a b
Right (Dyadic -> ConvertResult Dyadic)
-> (MPFloat -> Dyadic) -> MPFloat -> ConvertResult Dyadic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MPFloat -> Dyadic
Dyadic
instance HasIntegerBounds Dyadic where
integerBounds :: Dyadic -> (Integer, Integer)
integerBounds Dyadic
d = (Dyadic -> RoundType Dyadic
forall t. CanRound t => t -> RoundType t
floor Dyadic
d, Dyadic -> RoundType Dyadic
forall t. CanRound t => t -> RoundType t
ceiling Dyadic
d)
instance ConvertibleExactly Integer Dyadic where
safeConvertExactly :: Integer -> ConvertResult Dyadic
safeConvertExactly = (MPFloat -> Dyadic)
-> ConvertResult MPFloat -> ConvertResult Dyadic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MPFloat -> Dyadic
Dyadic (ConvertResult MPFloat -> ConvertResult Dyadic)
-> (Integer -> ConvertResult MPFloat)
-> Integer
-> ConvertResult Dyadic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ConvertResult MPFloat
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> ConvertResult t2
safeConvertExactly
instance ConvertibleExactly Int Dyadic where
safeConvertExactly :: Int -> ConvertResult Dyadic
safeConvertExactly = (MPFloat -> Dyadic)
-> ConvertResult MPFloat -> ConvertResult Dyadic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MPFloat -> Dyadic
Dyadic (ConvertResult MPFloat -> ConvertResult Dyadic)
-> (Int -> ConvertResult MPFloat) -> Int -> ConvertResult Dyadic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ConvertResult MPFloat
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> ConvertResult t2
safeConvertExactly
instance ConvertibleExactly Rational Dyadic where
safeConvertExactly :: Rational -> ConvertResult Dyadic
safeConvertExactly Rational
q
| Bool
EqCompareType Integer Rational
isDyadic = Dyadic -> ConvertResult Dyadic
forall a b. b -> Either a b
Right (Dyadic -> ConvertResult Dyadic) -> Dyadic -> ConvertResult Dyadic
forall a b. (a -> b) -> a -> b
$ MPFloat -> Dyadic
Dyadic (BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduCentre (BoundsCEDU MPFloat -> MPFloat) -> BoundsCEDU MPFloat -> MPFloat
forall a b. (a -> b) -> a -> b
$ Precision -> Rational -> BoundsCEDU MPFloat
fromRationalCEDU (Integer -> Precision
prec (Integer -> Precision) -> Integer -> Precision
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> MinMaxType Integer Integer
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max Integer
2 (Int
dp Int -> Int -> AddType Int Int
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
+ Int
np Integer -> Integer -> AddType Integer Integer
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
+ Integer
1)) Rational
q)
| Bool
otherwise = String -> Rational -> ConvertResult Dyadic
forall a b.
(Show a, Typeable a, Typeable b) =>
String -> a -> ConvertResult b
convError String
"this number is not dyadic" Rational
q
where
isDyadic :: EqCompareType Integer Rational
isDyadic = Integer
d Integer -> Rational -> EqCompareType Integer Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Integer
2Integer -> Int -> PowType Integer Int
forall t1 t2. CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
^Int
dp
dp :: Int
dp = Integer -> Int
integerLog2 Integer
d
d :: Integer
d = Rational -> Integer
forall a. Ratio a -> a
denominator Rational
q
np :: Int
np = Integer -> Int
integerLog2 (Integer -> Integer -> MinMaxType Integer Integer
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max Integer
1 (Integer -> MinMaxType Integer Integer)
-> Integer -> MinMaxType Integer Integer
forall a b. (a -> b) -> a -> b
$ Integer -> AbsType Integer
forall t. CanAbs t => t -> AbsType t
abs (Integer -> AbsType Integer) -> Integer -> AbsType Integer
forall a b. (a -> b) -> a -> b
$ Rational -> Integer
forall a. Ratio a -> a
numerator Rational
q)
instance Convertible Dyadic Double where
safeConvert :: Dyadic -> ConvertResult Double
safeConvert = MPFloat -> ConvertResult Double
forall a b. Convertible a b => a -> ConvertResult b
safeConvert (MPFloat -> ConvertResult Double)
-> (Dyadic -> MPFloat) -> Dyadic -> ConvertResult Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> MPFloat
dyadicMPFloat
instance (ConvertibleExactly Dyadic t, Monoid es) => ConvertibleExactly Dyadic (CollectErrors es t) where
safeConvertExactly :: Dyadic -> ConvertResult (CollectErrors es t)
safeConvertExactly = (t -> CollectErrors es t)
-> Either ConvertError t -> ConvertResult (CollectErrors es t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\t
v -> Maybe t -> es -> CollectErrors es t
forall es v. Maybe v -> es -> CollectErrors es v
CollectErrors (t -> Maybe t
forall a. a -> Maybe a
Just t
v) es
forall a. Monoid a => a
mempty) (Either ConvertError t -> ConvertResult (CollectErrors es t))
-> (Dyadic -> Either ConvertError t)
-> Dyadic
-> ConvertResult (CollectErrors es t)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> Either ConvertError t
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> ConvertResult t2
safeConvertExactly
instance HasEqAsymmetric Dyadic Dyadic
instance HasEqAsymmetric Dyadic Integer where
equalTo :: Dyadic -> Integer -> EqCompareType Dyadic Integer
equalTo = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Integer -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance HasEqAsymmetric Integer Dyadic where
equalTo :: Integer -> Dyadic -> EqCompareType Integer Dyadic
equalTo = (Dyadic -> Dyadic -> Bool) -> Integer -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance HasEqAsymmetric Dyadic Int where
equalTo :: Dyadic -> Int -> EqCompareType Dyadic Int
equalTo = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Int -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance HasEqAsymmetric Int Dyadic where
equalTo :: Int -> Dyadic -> EqCompareType Int Dyadic
equalTo = (Dyadic -> Dyadic -> Bool) -> Int -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance HasEqAsymmetric Dyadic Rational where
equalTo :: Dyadic -> Rational -> EqCompareType Dyadic Rational
equalTo = (Rational -> Rational -> Bool) -> Dyadic -> Rational -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance HasEqAsymmetric Rational Dyadic where
equalTo :: Rational -> Dyadic -> EqCompareType Rational Dyadic
equalTo = (Rational -> Rational -> Bool) -> Rational -> Dyadic -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Bool
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance
(HasEqAsymmetric Dyadic b
, IsBool (CollectErrors es (EqCompareType Dyadic b))
, CanBeErrors es)
=>
HasEqAsymmetric Dyadic (CollectErrors es b)
where
type EqCompareType Dyadic (CollectErrors es b) =
CollectErrors es (EqCompareType Dyadic b)
equalTo :: Dyadic
-> CollectErrors es b -> EqCompareType Dyadic (CollectErrors es b)
equalTo = (Dyadic -> b -> EqCompareType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (EqCompareType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> EqCompareType Dyadic b
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance
(HasEqAsymmetric a Dyadic
, IsBool (CollectErrors es (EqCompareType a Dyadic))
, CanBeErrors es)
=>
HasEqAsymmetric (CollectErrors es a) Dyadic
where
type EqCompareType (CollectErrors es a) Dyadic =
CollectErrors es (EqCompareType a Dyadic)
equalTo :: CollectErrors es a
-> Dyadic -> EqCompareType (CollectErrors es a) Dyadic
equalTo = (a -> Dyadic -> EqCompareType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (EqCompareType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> EqCompareType a Dyadic
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
equalTo
instance CanTestZero Dyadic
instance HasOrderAsymmetric Dyadic Dyadic
instance HasOrderAsymmetric Dyadic Integer where
lessThan :: Dyadic -> Integer -> OrderCompareType Dyadic Integer
lessThan = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Integer -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Dyadic -> Integer -> OrderCompareType Dyadic Integer
leq = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Integer -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance HasOrderAsymmetric Integer Dyadic where
lessThan :: Integer -> Dyadic -> OrderCompareType Integer Dyadic
lessThan = (Dyadic -> Dyadic -> Bool) -> Integer -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Integer -> Dyadic -> OrderCompareType Integer Dyadic
leq = (Dyadic -> Dyadic -> Bool) -> Integer -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance HasOrderAsymmetric Dyadic Int where
lessThan :: Dyadic -> Int -> OrderCompareType Dyadic Int
lessThan = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Int -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Dyadic -> Int -> OrderCompareType Dyadic Int
leq = (Dyadic -> Dyadic -> Bool) -> Dyadic -> Int -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance HasOrderAsymmetric Int Dyadic where
lessThan :: Int -> Dyadic -> OrderCompareType Int Dyadic
lessThan = (Dyadic -> Dyadic -> Bool) -> Int -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Int -> Dyadic -> OrderCompareType Int Dyadic
leq = (Dyadic -> Dyadic -> Bool) -> Int -> Dyadic -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance HasOrderAsymmetric Rational Dyadic where
lessThan :: Rational -> Dyadic -> OrderCompareType Rational Dyadic
lessThan = (Rational -> Rational -> Bool) -> Rational -> Dyadic -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Rational -> Dyadic -> OrderCompareType Rational Dyadic
leq = (Rational -> Rational -> Bool) -> Rational -> Dyadic -> Bool
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance HasOrderAsymmetric Dyadic Rational where
lessThan :: Dyadic -> Rational -> OrderCompareType Dyadic Rational
lessThan = (Rational -> Rational -> Bool) -> Dyadic -> Rational -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Dyadic -> Rational -> OrderCompareType Dyadic Rational
leq = (Rational -> Rational -> Bool) -> Dyadic -> Rational -> Bool
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Bool
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
instance
(HasOrderAsymmetric Dyadic b
, IsBool (CollectErrors es (OrderCompareType Dyadic b))
, CanBeErrors es)
=>
HasOrderAsymmetric Dyadic (CollectErrors es b)
where
type OrderCompareType Dyadic (CollectErrors es b) =
CollectErrors es (OrderCompareType Dyadic b)
lessThan :: Dyadic
-> CollectErrors es b
-> OrderCompareType Dyadic (CollectErrors es b)
lessThan = (Dyadic -> b -> OrderCompareType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (OrderCompareType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> OrderCompareType Dyadic b
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: Dyadic
-> CollectErrors es b
-> OrderCompareType Dyadic (CollectErrors es b)
leq = (Dyadic -> b -> OrderCompareType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (OrderCompareType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> OrderCompareType Dyadic b
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
greaterThan :: Dyadic
-> CollectErrors es b
-> OrderCompareType Dyadic (CollectErrors es b)
greaterThan = (Dyadic -> b -> OrderCompareType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (OrderCompareType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> OrderCompareType Dyadic b
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
greaterThan
geq :: Dyadic
-> CollectErrors es b
-> OrderCompareType Dyadic (CollectErrors es b)
geq = (Dyadic -> b -> OrderCompareType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (OrderCompareType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> OrderCompareType Dyadic b
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
geq
instance
(HasOrderAsymmetric a Dyadic
, IsBool (CollectErrors es (OrderCompareType a Dyadic))
, CanBeErrors es)
=>
HasOrderAsymmetric (CollectErrors es a) Dyadic
where
type OrderCompareType (CollectErrors es a) Dyadic =
CollectErrors es (OrderCompareType a Dyadic)
lessThan :: CollectErrors es a
-> Dyadic -> OrderCompareType (CollectErrors es a) Dyadic
lessThan = (a -> Dyadic -> OrderCompareType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (OrderCompareType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> OrderCompareType a Dyadic
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
lessThan
leq :: CollectErrors es a
-> Dyadic -> OrderCompareType (CollectErrors es a) Dyadic
leq = (a -> Dyadic -> OrderCompareType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (OrderCompareType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> OrderCompareType a Dyadic
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
leq
greaterThan :: CollectErrors es a
-> Dyadic -> OrderCompareType (CollectErrors es a) Dyadic
greaterThan = (a -> Dyadic -> OrderCompareType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (OrderCompareType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> OrderCompareType a Dyadic
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
greaterThan
geq :: CollectErrors es a
-> Dyadic -> OrderCompareType (CollectErrors es a) Dyadic
geq = (a -> Dyadic -> OrderCompareType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (OrderCompareType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> OrderCompareType a Dyadic
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
geq
instance CanTestPosNeg Dyadic
instance CanTestInteger Dyadic where
certainlyNotInteger :: Dyadic -> Bool
certainlyNotInteger = Rational -> Bool
forall t. CanTestInteger t => t -> Bool
certainlyNotInteger (Rational -> Bool) -> (Dyadic -> Rational) -> Dyadic -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational
certainlyIntegerGetIt :: Dyadic -> Maybe Integer
certainlyIntegerGetIt = Rational -> Maybe Integer
forall t. CanTestInteger t => t -> Maybe Integer
certainlyIntegerGetIt (Rational -> Maybe Integer)
-> (Dyadic -> Rational) -> Dyadic -> Maybe Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational
instance CanNeg Dyadic where
negate :: Dyadic -> NegType Dyadic
negate = (MPFloat -> MPFloat) -> Dyadic -> Dyadic
lift1 MPFloat -> MPFloat
forall t. CanNeg t => t -> NegType t
negate
instance CanAbs Dyadic where
abs :: Dyadic -> AbsType Dyadic
abs = (MPFloat -> MPFloat) -> Dyadic -> Dyadic
lift1 MPFloat -> MPFloat
forall t. CanAbs t => t -> AbsType t
abs
lift1 :: (MPFloat -> MPFloat) -> (Dyadic -> Dyadic)
lift1 :: (MPFloat -> MPFloat) -> Dyadic -> Dyadic
lift1 MPFloat -> MPFloat
op (Dyadic MPFloat
x) = MPFloat -> Dyadic
Dyadic (MPFloat -> MPFloat
op MPFloat
x)
instance CanMinMaxAsymmetric Dyadic Dyadic
instance CanMinMaxAsymmetric Integer Dyadic where
type MinMaxType Integer Dyadic = Dyadic
min :: Integer -> Dyadic -> MinMaxType Integer Dyadic
min = (Dyadic -> Dyadic -> Dyadic) -> Integer -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Integer -> Dyadic -> MinMaxType Integer Dyadic
max = (Dyadic -> Dyadic -> Dyadic) -> Integer -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanMinMaxAsymmetric Dyadic Integer where
type MinMaxType Dyadic Integer = Dyadic
min :: Dyadic -> Integer -> MinMaxType Dyadic Integer
min = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Dyadic -> Integer -> MinMaxType Dyadic Integer
max = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanMinMaxAsymmetric Int Dyadic where
type MinMaxType Int Dyadic = Dyadic
min :: Int -> Dyadic -> MinMaxType Int Dyadic
min = (Dyadic -> Dyadic -> Dyadic) -> Int -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Int -> Dyadic -> MinMaxType Int Dyadic
max = (Dyadic -> Dyadic -> Dyadic) -> Int -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanMinMaxAsymmetric Dyadic Int where
type MinMaxType Dyadic Int = Dyadic
min :: Dyadic -> Int -> MinMaxType Dyadic Int
min = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Dyadic -> Int -> MinMaxType Dyadic Int
max = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanMinMaxAsymmetric Rational Dyadic where
type MinMaxType Rational Dyadic = Rational
min :: Rational -> Dyadic -> MinMaxType Rational Dyadic
min = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Rational -> Dyadic -> MinMaxType Rational Dyadic
max = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanMinMaxAsymmetric Dyadic Rational where
type MinMaxType Dyadic Rational = Rational
min :: Dyadic -> Rational -> MinMaxType Dyadic Rational
min = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Dyadic -> Rational -> MinMaxType Dyadic Rational
max = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance
(CanMinMaxAsymmetric Dyadic b
, CanBeErrors es)
=>
CanMinMaxAsymmetric Dyadic (CollectErrors es b)
where
type MinMaxType Dyadic (CollectErrors es b) =
CollectErrors es (MinMaxType Dyadic b)
min :: Dyadic
-> CollectErrors es b -> MinMaxType Dyadic (CollectErrors es b)
min = (Dyadic -> b -> MinMaxType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (MinMaxType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> MinMaxType Dyadic b
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: Dyadic
-> CollectErrors es b -> MinMaxType Dyadic (CollectErrors es b)
max = (Dyadic -> b -> MinMaxType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (MinMaxType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> MinMaxType Dyadic b
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance
(CanMinMaxAsymmetric a Dyadic
, CanBeErrors es)
=>
CanMinMaxAsymmetric (CollectErrors es a) Dyadic
where
type MinMaxType (CollectErrors es a) Dyadic =
CollectErrors es (MinMaxType a Dyadic)
min :: CollectErrors es a
-> Dyadic -> MinMaxType (CollectErrors es a) Dyadic
min = (a -> Dyadic -> MinMaxType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (MinMaxType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> MinMaxType a Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
min
max :: CollectErrors es a
-> Dyadic -> MinMaxType (CollectErrors es a) Dyadic
max = (a -> Dyadic -> MinMaxType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (MinMaxType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> MinMaxType a Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
max
instance CanAddAsymmetric Dyadic Dyadic where
add :: Dyadic -> Dyadic -> AddType Dyadic Dyadic
add = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> Dyadic -> Dyadic -> Dyadic
lift2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
addCEDU
instance CanAddAsymmetric Integer Dyadic where
type AddType Integer Dyadic = Dyadic
add :: Integer -> Dyadic -> AddType Integer Dyadic
add = (Dyadic -> Dyadic -> Dyadic) -> Integer -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanAddAsymmetric Dyadic Integer where
type AddType Dyadic Integer = Dyadic
add :: Dyadic -> Integer -> AddType Dyadic Integer
add = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanAddAsymmetric Int Dyadic where
type AddType Int Dyadic = Dyadic
add :: Int -> Dyadic -> AddType Int Dyadic
add = (Dyadic -> Dyadic -> Dyadic) -> Int -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanAddAsymmetric Dyadic Int where
type AddType Dyadic Int = Dyadic
add :: Dyadic -> Int -> AddType Dyadic Int
add = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanAddAsymmetric Rational Dyadic where
type AddType Rational Dyadic = Rational
add :: Rational -> Dyadic -> AddType Rational Dyadic
add = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanAddAsymmetric Dyadic Rational where
type AddType Dyadic Rational = Rational
add :: Dyadic -> Rational -> AddType Dyadic Rational
add = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance
(CanAddAsymmetric Dyadic b
, CanBeErrors es)
=>
CanAddAsymmetric Dyadic (CollectErrors es b)
where
type AddType Dyadic (CollectErrors es b) =
CollectErrors es (AddType Dyadic b)
add :: Dyadic -> CollectErrors es b -> AddType Dyadic (CollectErrors es b)
add = (Dyadic -> b -> AddType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (AddType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> AddType Dyadic b
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance
(CanAddAsymmetric a Dyadic
, CanBeErrors es)
=>
CanAddAsymmetric (CollectErrors es a) Dyadic
where
type AddType (CollectErrors es a) Dyadic =
CollectErrors es (AddType a Dyadic)
add :: CollectErrors es a -> Dyadic -> AddType (CollectErrors es a) Dyadic
add = (a -> Dyadic -> AddType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (AddType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> AddType a Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
add
instance CanSub Dyadic Dyadic where
sub :: Dyadic -> Dyadic -> SubType Dyadic Dyadic
sub = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> Dyadic -> Dyadic -> Dyadic
lift2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
subCEDU
instance CanSub Integer Dyadic where
type SubType Integer Dyadic = Dyadic
sub :: Integer -> Dyadic -> SubType Integer Dyadic
sub = (Dyadic -> Dyadic -> Dyadic) -> Integer -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanSub Dyadic Integer where
type SubType Dyadic Integer = Dyadic
sub :: Dyadic -> Integer -> SubType Dyadic Integer
sub = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanSub Int Dyadic where
type SubType Int Dyadic = Dyadic
sub :: Int -> Dyadic -> SubType Int Dyadic
sub = (Dyadic -> Dyadic -> Dyadic) -> Int -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanSub Dyadic Int where
type SubType Dyadic Int = Dyadic
sub :: Dyadic -> Int -> SubType Dyadic Int
sub = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanSub Rational Dyadic where
type SubType Rational Dyadic = Rational
sub :: Rational -> Dyadic -> SubType Rational Dyadic
sub = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanSub Dyadic Rational where
type SubType Dyadic Rational = Rational
sub :: Dyadic -> Rational -> SubType Dyadic Rational
sub = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance
(CanSub Dyadic b
, CanBeErrors es)
=>
CanSub Dyadic (CollectErrors es b)
where
type SubType Dyadic (CollectErrors es b) =
CollectErrors es (SubType Dyadic b)
sub :: Dyadic -> CollectErrors es b -> SubType Dyadic (CollectErrors es b)
sub = (Dyadic -> b -> SubType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (SubType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> SubType Dyadic b
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance
(CanSub a Dyadic
, CanBeErrors es)
=>
CanSub (CollectErrors es a) Dyadic
where
type SubType (CollectErrors es a) Dyadic =
CollectErrors es (SubType a Dyadic)
sub :: CollectErrors es a -> Dyadic -> SubType (CollectErrors es a) Dyadic
sub = (a -> Dyadic -> SubType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (SubType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> SubType a Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
sub
instance CanMulAsymmetric Dyadic Dyadic where
mul :: Dyadic -> Dyadic -> MulType Dyadic Dyadic
mul = (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> Dyadic -> Dyadic -> Dyadic
lift2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
mulCEDU
instance CanMulAsymmetric Integer Dyadic where
type MulType Integer Dyadic = Dyadic
mul :: Integer -> Dyadic -> MulType Integer Dyadic
mul = (Dyadic -> Dyadic -> Dyadic) -> Integer -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanMulAsymmetric Dyadic Integer where
type MulType Dyadic Integer = Dyadic
mul :: Dyadic -> Integer -> MulType Dyadic Integer
mul = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanMulAsymmetric Int Dyadic where
type MulType Int Dyadic = Dyadic
mul :: Int -> Dyadic -> MulType Int Dyadic
mul = (Dyadic -> Dyadic -> Dyadic) -> Int -> Dyadic -> Dyadic
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanMulAsymmetric Dyadic Int where
type MulType Dyadic Int = Dyadic
mul :: Dyadic -> Int -> MulType Dyadic Int
mul = (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanMulAsymmetric Rational Dyadic where
type MulType Rational Dyadic = Rational
mul :: Rational -> Dyadic -> MulType Rational Dyadic
mul = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanMulAsymmetric Dyadic Rational where
type MulType Dyadic Rational = Rational
mul :: Dyadic -> Rational -> MulType Dyadic Rational
mul = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance
(CanMulAsymmetric Dyadic b
, CanBeErrors es)
=>
CanMulAsymmetric Dyadic (CollectErrors es b)
where
type MulType Dyadic (CollectErrors es b) =
CollectErrors es (MulType Dyadic b)
mul :: Dyadic -> CollectErrors es b -> MulType Dyadic (CollectErrors es b)
mul = (Dyadic -> b -> MulType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (MulType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> MulType Dyadic b
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance
(CanMulAsymmetric a Dyadic
, CanBeErrors es)
=>
CanMulAsymmetric (CollectErrors es a) Dyadic
where
type MulType (CollectErrors es a) Dyadic =
CollectErrors es (MulType a Dyadic)
mul :: CollectErrors es a -> Dyadic -> MulType (CollectErrors es a) Dyadic
mul = (a -> Dyadic -> MulType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (MulType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> MulType a Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
mul
instance CanPow Dyadic Integer where
pow :: Dyadic -> Integer -> PowType Dyadic Integer
pow = Dyadic
-> (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Integer -> Dyadic
forall e t. CanBeInteger e => t -> (t -> t -> t) -> t -> e -> t
powUsingMul (Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Integer
1) Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
(*)
instance CanPow Dyadic Int where
pow :: Dyadic -> Int -> PowType Dyadic Int
pow = Dyadic -> (Dyadic -> Dyadic -> Dyadic) -> Dyadic -> Int -> Dyadic
forall e t. CanBeInteger e => t -> (t -> t -> t) -> t -> e -> t
powUsingMul (Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Integer
1) Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
(*)
instance
(CanDiv a Dyadic
, CanBeErrors es)
=>
CanDiv (CollectErrors es a) Dyadic
where
type DivType (CollectErrors es a) Dyadic =
CollectErrors es (DivType a Dyadic)
divide :: CollectErrors es a -> Dyadic -> DivType (CollectErrors es a) Dyadic
divide = (a -> Dyadic -> DivType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (DivType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> DivType a Dyadic
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide
instance CanDiv Integer Dyadic where
type DivType Integer Dyadic = Rational
divide :: Integer -> Dyadic -> DivType Integer Dyadic
divide Integer
a Dyadic
b = Integer -> Rational -> DivType Integer Rational
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide Integer
a (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
b)
instance CanDiv Dyadic Integer where
type DivType Dyadic Integer = Rational
divide :: Dyadic -> Integer -> DivType Dyadic Integer
divide Dyadic
a Integer
b = Rational -> Integer -> DivType Rational Integer
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
a) Integer
b
instance CanDiv Int Dyadic where
type DivType Int Dyadic = Rational
divide :: Int -> Dyadic -> DivType Int Dyadic
divide Int
a Dyadic
b = Int -> Rational -> DivType Int Rational
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide Int
a (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
b)
instance CanDiv Dyadic Int where
type DivType Dyadic Int = Rational
divide :: Dyadic -> Int -> DivType Dyadic Int
divide Dyadic
a Int
b = Rational -> Int -> DivType Rational Int
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
a) Int
b
instance CanDiv Rational Dyadic where
type DivType Rational Dyadic = Rational
divide :: Rational -> Dyadic -> DivType Rational Dyadic
divide = (Rational -> Rational -> Rational)
-> Rational -> Dyadic -> Rational
forall b a c.
ConvertibleExactly b a =>
(a -> a -> c) -> a -> b -> c
convertSecond Rational -> Rational -> Rational
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide
instance CanDiv Dyadic Rational where
type DivType Dyadic Rational = Rational
divide :: Dyadic -> Rational -> DivType Dyadic Rational
divide = (Rational -> Rational -> Rational)
-> Dyadic -> Rational -> Rational
forall a b c.
ConvertibleExactly a b =>
(b -> b -> c) -> a -> b -> c
convertFirst Rational -> Rational -> Rational
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide
instance
(CanDiv Dyadic b
, CanBeErrors es)
=>
CanDiv Dyadic (CollectErrors es b)
where
type DivType Dyadic (CollectErrors es b) =
CollectErrors es (DivType Dyadic b)
divide :: Dyadic -> CollectErrors es b -> DivType Dyadic (CollectErrors es b)
divide = (Dyadic -> b -> DivType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (DivType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> DivType Dyadic b
forall t1 t2. CanDiv t1 t2 => t1 -> t2 -> DivType t1 t2
divide
instance
(CanPow Dyadic b
, CanBeErrors es)
=>
CanPow Dyadic (CollectErrors es b)
where
type PowType Dyadic (CollectErrors es b) =
CollectErrors es (PowType Dyadic b)
pow :: Dyadic -> CollectErrors es b -> PowType Dyadic (CollectErrors es b)
pow = (Dyadic -> b -> PowType Dyadic b)
-> Dyadic
-> CollectErrors es b
-> CollectErrors es (PowType Dyadic b)
forall es a b c.
Monoid es =>
(a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
CE.liftT1 Dyadic -> b -> PowType Dyadic b
forall t1 t2. CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
pow
instance
(CanPow a Dyadic
, CanBeErrors es)
=>
CanPow (CollectErrors es a) Dyadic
where
type PowType (CollectErrors es a) Dyadic =
CollectErrors es (PowType a Dyadic)
pow :: CollectErrors es a -> Dyadic -> PowType (CollectErrors es a) Dyadic
pow = (a -> Dyadic -> PowType a Dyadic)
-> CollectErrors es a
-> Dyadic
-> CollectErrors es (PowType a Dyadic)
forall es a b c.
Monoid es =>
(a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
CE.lift1T a -> Dyadic -> PowType a Dyadic
forall t1 t2. CanPow t1 t2 => t1 -> t2 -> PowType t1 t2
pow
instance CanTestFinite Dyadic where
isFinite :: Dyadic -> Bool
isFinite = MPFloat -> Bool
forall t. CanTestFinite t => t -> Bool
isFinite (MPFloat -> Bool) -> (Dyadic -> MPFloat) -> Dyadic -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> MPFloat
dyadicMPFloat
isInfinite :: Dyadic -> Bool
isInfinite = MPFloat -> Bool
forall t. CanTestFinite t => t -> Bool
isInfinite (MPFloat -> Bool) -> (Dyadic -> MPFloat) -> Dyadic -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dyadic -> MPFloat
dyadicMPFloat
lift2 ::
(MPFloat -> MPFloat -> BoundsCEDU MPFloat) ->
(Dyadic -> Dyadic -> Dyadic)
lift2 :: (MPFloat -> MPFloat -> BoundsCEDU MPFloat)
-> Dyadic -> Dyadic -> Dyadic
lift2 MPFloat -> MPFloat -> BoundsCEDU MPFloat
opCEDU (Dyadic MPFloat
x0) (Dyadic MPFloat
y0) = MPFloat -> Dyadic
Dyadic (MPFloat -> MPFloat -> MPFloat
opExact MPFloat
x0 MPFloat
y0)
where
opExact :: MPFloat -> MPFloat -> MPFloat
opExact MPFloat
x MPFloat
y
| MPFloat
rE MPFloat -> MPFloat -> Bool
forall a. Eq a => a -> a -> Bool
P.== MPFloat
zero = MPFloat
rC
| Bool
otherwise =
maybeTrace (printf "Dyadic.lift2: rC = %s; rE = %s; p = %s" (show rC) (show rE) (show $ integer p)) $
MPFloat -> MPFloat -> MPFloat
opExact MPFloat
xH MPFloat
yH
where
rC :: MPFloat
rC = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduCentre BoundsCEDU MPFloat
rCEDU
rE :: MPFloat
rE = BoundsCEDU MPFloat -> MPFloat
forall a. BoundsCEDU a -> a
ceduErr BoundsCEDU MPFloat
rCEDU
rCEDU :: BoundsCEDU MPFloat
rCEDU = MPFloat -> MPFloat -> BoundsCEDU MPFloat
opCEDU MPFloat
x MPFloat
y
xH :: MPFloat
xH = Precision -> MPFloat -> MPFloat
forall t. CanSetPrecision t => Precision -> t -> t
setPrecision Precision
pH MPFloat
x
yH :: MPFloat
yH = Precision -> MPFloat -> MPFloat
forall t. CanSetPrecision t => Precision -> t -> t
setPrecision Precision
pH MPFloat
y
pH :: Precision
pH = Precision -> Precision
precisionTimes2 Precision
p
p :: Precision
p = MPFloat -> Precision
forall t. HasPrecision t => t -> Precision
getPrecision MPFloat
rC
instance Arbitrary Dyadic where
arbitrary :: Gen Dyadic
arbitrary =
do
MPFloat
c <- Gen MPFloat
finiteMPFloat
Dyadic -> Gen Dyadic
forall (m :: * -> *) a. Monad m => a -> m a
return (MPFloat -> Dyadic
Dyadic MPFloat
c)
where
finiteMPFloat :: Gen MPFloat
finiteMPFloat =
do
MPFloat
x <- Gen MPFloat
forall a. Arbitrary a => Gen a
arbitrary
if MPFloat -> Bool
forall t. CanTestFinite t => t -> Bool
isFinite MPFloat
x
then MPFloat -> Gen MPFloat
forall (m :: * -> *) a. Monad m => a -> m a
return MPFloat
x
else Gen MPFloat
finiteMPFloat
tDyadic :: T Dyadic
tDyadic :: T Dyadic
tDyadic = String -> T Dyadic
forall t. String -> T t
T String
"Dyadic"
specDyadic :: Spec
specDyadic :: Spec
specDyadic =
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (String
"Dyadic") (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
T Integer
-> T Dyadic -> (Integer -> Dyadic) -> (Dyadic -> Integer) -> Spec
forall t1 t2.
(Arbitrary t1, Show t1, HasEqCertainly t1 t1) =>
T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec
specConversion T Integer
tInteger T Dyadic
tDyadic Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Dyadic -> Integer
forall t. CanRound t => t -> RoundType t
round
T Dyadic
-> T Rational
-> (Dyadic -> Rational)
-> (Rational -> Dyadic)
-> Spec
forall t1 t2.
(Arbitrary t1, Show t1, HasEqCertainly t1 t1) =>
T t1 -> T t2 -> (t1 -> t2) -> (t2 -> t1) -> Spec
specConversion T Dyadic
tDyadic T Rational
tRational Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Rational -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"order" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
T Dyadic -> Spec
forall t.
(Arbitrary t, Show t, CanTestCertainly (EqCompareType t t),
CanTestCertainly
(AndOrType (EqCompareType t t) (EqCompareType t t)),
HasEqAsymmetric t t) =>
T t -> Spec
specHasEqNotMixed T Dyadic
tDyadic
T Int -> T Dyadic -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3, Show t1, Show t2,
Show t3, CanTestCertainly (EqCompareType t1 t1),
CanTestCertainly (EqCompareType t1 t2),
CanTestCertainly (EqCompareType t2 t1),
CanTestCertainly
(AndOrType (EqCompareType t1 t2) (EqCompareType t2 t3)),
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
specHasEq T Int
tInt T Dyadic
tDyadic T Rational
tRational
T Dyadic -> Spec
forall t.
(CanTestZero t, ConvertibleExactly Integer t) =>
T t -> Spec
specCanTestZero T Dyadic
tDyadic
T Dyadic -> Spec
forall t.
(Arbitrary t, Show t, CanTestCertainly (OrderCompareType t t),
CanTestCertainly
(AndOrType (OrderCompareType t t) (OrderCompareType t t)),
HasOrderAsymmetric t t) =>
T t -> Spec
specHasOrderNotMixed T Dyadic
tDyadic
T Int -> T Dyadic -> T Rational -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3, Show t1, Show t2,
Show t3, CanTestCertainly (OrderCompareType t1 t1),
CanTestCertainly (OrderCompareType t1 t2),
CanTestCertainly (OrderCompareType t2 t1),
CanTestCertainly
(AndOrType (OrderCompareType t1 t2) (OrderCompareType t2 t3)),
CanTestCertainly (OrderCompareType t2 t3),
HasOrderAsymmetric t1 t1, HasOrderAsymmetric t1 t2,
HasOrderAsymmetric t2 t1, HasOrderAsymmetric t2 t3,
CanAndOrAsymmetric
(OrderCompareType t1 t2) (OrderCompareType t2 t3)) =>
T t1 -> T t2 -> T t3 -> Spec
specHasOrder T Int
tInt T Dyadic
tDyadic T Rational
tRational
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"min/max/abs" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
T Dyadic -> Spec
forall t.
(Arbitrary t, Show t, Show (NegType (NegType t)),
HasEqAsymmetric t t, HasEqAsymmetric (NegType (NegType t)) t,
HasEqAsymmetric (NegType t) t,
CanTestCertainly (EqCompareType t t),
CanTestCertainly (EqCompareType (NegType (NegType t)) t),
CanTestCertainly (EqCompareType (NegType t) t), CanTestFinite t,
CanTestPosNeg t, CanTestPosNeg (NegType t),
ConvertibleExactly Integer t, CanNeg (NegType t), CanNeg t) =>
T t -> Spec
specCanNegNum T Dyadic
tDyadic
T Dyadic -> Spec
forall t.
(Arbitrary t, CanAbs (AbsType t), CanAbs t, CanTestFinite t,
HasEqAsymmetric (AbsType (AbsType t)) (AbsType t),
HasEqAsymmetric t t, HasEqAsymmetric t (AbsType t),
HasEqAsymmetric (NegType t) (AbsType t),
CanTestCertainly (EqCompareType t t),
CanTestCertainly (EqCompareType (AbsType (AbsType t)) (AbsType t)),
CanTestCertainly (EqCompareType t (AbsType t)),
CanTestCertainly (EqCompareType (NegType t) (AbsType t)), Show t,
Show (AbsType (AbsType t)), Show (AbsType t), Show (NegType t),
CanTestPosNeg t, CanTestPosNeg (AbsType t), CanNeg t) =>
T t -> Spec
specCanAbs T Dyadic
tDyadic
T Dyadic -> Spec
forall t.
(HasOrderAsymmetric (MinMaxType t t) t, Arbitrary t,
CanTestFinite t, HasEqAsymmetric (MinMaxType t t) t,
HasEqAsymmetric (MinMaxType t t) (MinMaxType t t),
HasEqAsymmetric
(MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t),
CanTestCertainly (OrderCompareType (MinMaxType t t) t),
CanTestCertainly (EqCompareType (MinMaxType t t) t),
CanTestCertainly (EqCompareType (MinMaxType t t) (MinMaxType t t)),
CanTestCertainly
(EqCompareType
(MinMaxType t (MinMaxType t t)) (MinMaxType (MinMaxType t t) t)),
Show t, Show (MinMaxType t t),
Show (MinMaxType t (MinMaxType t t)),
Show (MinMaxType (MinMaxType t t) t), CanMinMaxAsymmetric t t,
CanMinMaxAsymmetric t (MinMaxType t t),
CanMinMaxAsymmetric (MinMaxType t t) t) =>
T t -> Spec
specCanMinMaxNotMixed T Dyadic
tDyadic
T Dyadic -> T Integer -> T Dyadic -> Spec
forall t1 t2 t3.
(HasOrderAsymmetric (MinMaxType t1 t2) t2,
HasOrderAsymmetric (MinMaxType t1 t2) t1, Arbitrary t1,
Arbitrary t2, Arbitrary t3, CanTestFinite t1, CanTestFinite t2,
CanTestFinite t3, HasEqAsymmetric (MinMaxType t1 t1) t1,
HasEqAsymmetric (MinMaxType t1 t2) (MinMaxType t2 t1),
HasEqAsymmetric
(MinMaxType t1 (MinMaxType t2 t3))
(MinMaxType (MinMaxType t1 t2) t3),
CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t2),
CanTestCertainly (OrderCompareType (MinMaxType t1 t2) t1),
CanTestCertainly (EqCompareType (MinMaxType t1 t1) t1),
CanTestCertainly
(EqCompareType (MinMaxType t1 t2) (MinMaxType t2 t1)),
CanTestCertainly
(EqCompareType
(MinMaxType t1 (MinMaxType t2 t3))
(MinMaxType (MinMaxType t1 t2) t3)),
Show t1, Show t2, Show (MinMaxType t1 t2), Show (MinMaxType t1 t1),
Show (MinMaxType t2 t1), Show t3,
Show (MinMaxType t1 (MinMaxType t2 t3)),
Show (MinMaxType (MinMaxType t1 t2) t3), CanMinMaxAsymmetric t1 t2,
CanMinMaxAsymmetric t1 t1,
CanMinMaxAsymmetric t1 (MinMaxType t2 t3),
CanMinMaxAsymmetric t2 t1, CanMinMaxAsymmetric t2 t3,
CanMinMaxAsymmetric (MinMaxType t1 t2) t3) =>
T t1 -> T t2 -> T t3 -> Spec
specCanMinMax T Dyadic
tDyadic T Integer
tInteger T Dyadic
tDyadic
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"min Dyadic Rational (dyadic only)" (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$ do
(Dyadic -> Dyadic -> Bool) -> Property
forall prop. Testable prop => prop -> Property
property ((Dyadic -> Dyadic -> Bool) -> Property)
-> (Dyadic -> Dyadic -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \ (Dyadic
x :: Dyadic) (Dyadic
y :: Dyadic) ->
Dyadic
x Dyadic -> Dyadic -> MinMaxType Dyadic Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
`min` Dyadic
y Dyadic -> Rational -> EqCompareType Dyadic Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Dyadic
x Dyadic -> Rational -> MinMaxType Dyadic Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
`min` (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
y)
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"max Dyadic Rational (dyadic only)" (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$ do
(Dyadic -> Dyadic -> Bool) -> Property
forall prop. Testable prop => prop -> Property
property ((Dyadic -> Dyadic -> Bool) -> Property)
-> (Dyadic -> Dyadic -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \ (Dyadic
x :: Dyadic) (Dyadic
y :: Dyadic) ->
Dyadic
x Dyadic -> Dyadic -> MinMaxType Dyadic Dyadic
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
`max` Dyadic
y Dyadic -> Rational -> EqCompareType Dyadic Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Dyadic
x Dyadic -> Rational -> MinMaxType Dyadic Rational
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
`max` (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
y)
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"ring" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
T Dyadic -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (AddType t t) t,
HasEqAsymmetric (AddType t t) (AddType t t),
HasEqAsymmetric
(AddType t (AddType t t)) (AddType (AddType t t) t),
Show t, Show (AddType t t), Show (AddType t (AddType t t)),
Show (AddType (AddType t t) t), CanAddAsymmetric t t,
CanAddAsymmetric t (AddType t t), CanAddAsymmetric (AddType t t) t,
CanTestPosNeg t, HasOrderAsymmetric (AddType t t) t,
CanTestCertainly (EqCompareType (AddType t t) t),
CanTestCertainly (EqCompareType (AddType t t) (AddType t t)),
CanTestCertainly
(EqCompareType
(AddType t (AddType t t)) (AddType (AddType t t) t)),
CanTestCertainly (OrderCompareType (AddType t t) t),
ConvertibleExactly Integer t) =>
T t -> Spec
specCanAddNotMixed T Dyadic
tDyadic
T Dyadic -> Spec
forall t.
(ConvertibleExactly Integer t, Show t, HasEqCertainly t t,
CanAddSameType t) =>
T t -> Spec
specCanAddSameType T Dyadic
tDyadic
T Int -> T Dyadic -> T Integer -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
HasEqAsymmetric (AddType t1 t1) t1,
HasEqAsymmetric (AddType t1 t2) (AddType t2 t1),
HasEqAsymmetric
(AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3),
Show t1, Show (AddType t1 t1), Show t2, Show (AddType t1 t2),
Show (AddType t2 t1), Show t3, Show (AddType t1 (AddType t2 t3)),
Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t1,
CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3),
CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3,
CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1,
HasOrderAsymmetric (AddType t1 t2) t2,
CanTestCertainly (EqCompareType (AddType t1 t1) t1),
CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)),
CanTestCertainly
(EqCompareType
(AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)),
CanTestCertainly (OrderCompareType (AddType t1 t2) t2),
ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> T t3 -> Spec
specCanAdd T Int
tInt T Dyadic
tDyadic T Integer
tInteger
T Integer -> T Dyadic -> T Int -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
HasEqAsymmetric (AddType t1 t1) t1,
HasEqAsymmetric (AddType t1 t2) (AddType t2 t1),
HasEqAsymmetric
(AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3),
Show t1, Show (AddType t1 t1), Show t2, Show (AddType t1 t2),
Show (AddType t2 t1), Show t3, Show (AddType t1 (AddType t2 t3)),
Show (AddType (AddType t1 t2) t3), CanAddAsymmetric t1 t1,
CanAddAsymmetric t1 t2, CanAddAsymmetric t1 (AddType t2 t3),
CanAddAsymmetric t2 t1, CanAddAsymmetric t2 t3,
CanAddAsymmetric (AddType t1 t2) t3, CanTestPosNeg t1,
HasOrderAsymmetric (AddType t1 t2) t2,
CanTestCertainly (EqCompareType (AddType t1 t1) t1),
CanTestCertainly (EqCompareType (AddType t1 t2) (AddType t2 t1)),
CanTestCertainly
(EqCompareType
(AddType t1 (AddType t2 t3)) (AddType (AddType t1 t2) t3)),
CanTestCertainly (OrderCompareType (AddType t1 t2) t2),
ConvertibleExactly Integer t1) =>
T t1 -> T t2 -> T t3 -> Spec
specCanAdd T Integer
tInteger T Dyadic
tDyadic T Int
tInt
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"Dyadic + Rational (dyadic only)" (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$ do
(Dyadic -> Dyadic -> Bool) -> Property
forall prop. Testable prop => prop -> Property
property ((Dyadic -> Dyadic -> Bool) -> Property)
-> (Dyadic -> Dyadic -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \ (Dyadic
x :: Dyadic) (Dyadic
y :: Dyadic) ->
Dyadic
x Dyadic -> Dyadic -> AddType Dyadic Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
+ Dyadic
y Dyadic -> Rational -> EqCompareType Dyadic Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Dyadic
x Dyadic -> Rational -> AddType Dyadic Rational
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
+ (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
y)
T Dyadic -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (SubType t t) t,
HasEqAsymmetric (SubType t t) (AddType t (NegType t)),
CanTestCertainly (EqCompareType (SubType t t) t),
CanTestCertainly
(EqCompareType (SubType t t) (AddType t (NegType t))),
Show t, Show (SubType t t), Show (AddType t (NegType t)),
CanSub t t, CanAddAsymmetric t (NegType t),
ConvertibleExactly Integer t, CanNeg t) =>
T t -> Spec
specCanSubNotMixed T Dyadic
tDyadic
T Dyadic -> T Integer -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
CanTestCertainly (EqCompareType (SubType t1 t1) t1),
CanTestCertainly
(EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Dyadic
tDyadic T Integer
tInteger
T Integer -> T Dyadic -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
CanTestCertainly (EqCompareType (SubType t1 t1) t1),
CanTestCertainly
(EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Integer
tInteger T Dyadic
tDyadic
T Dyadic -> T Int -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
CanTestCertainly (EqCompareType (SubType t1 t1) t1),
CanTestCertainly
(EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Dyadic
tDyadic T Int
tInt
T Int -> T Dyadic -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, HasEqAsymmetric (SubType t1 t1) t1,
HasEqAsymmetric (SubType t1 t2) (AddType t1 (NegType t2)),
CanTestCertainly (EqCompareType (SubType t1 t1) t1),
CanTestCertainly
(EqCompareType (SubType t1 t2) (AddType t1 (NegType t2))),
Show t1, Show (SubType t1 t1), Show t2, Show (SubType t1 t2),
Show (AddType t1 (NegType t2)), CanSub t1 t1, CanSub t1 t2,
CanAddAsymmetric t1 (NegType t2), ConvertibleExactly Integer t1,
CanNeg t2) =>
T t1 -> T t2 -> Spec
specCanSub T Int
tInt T Dyadic
tDyadic
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"Dyadic - Rational (dyadic only)" (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$ do
(Dyadic -> Dyadic -> Bool) -> Property
forall prop. Testable prop => prop -> Property
property ((Dyadic -> Dyadic -> Bool) -> Property)
-> (Dyadic -> Dyadic -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \ (Dyadic
x :: Dyadic) (Dyadic
y :: Dyadic) ->
Dyadic
x Dyadic -> Dyadic -> SubType Dyadic Dyadic
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- Dyadic
y Dyadic -> Rational -> EqCompareType Dyadic Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Dyadic
x Dyadic -> Rational -> SubType Dyadic Rational
forall t1 t2. CanSub t1 t2 => t1 -> t2 -> SubType t1 t2
- (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
y)
T Dyadic -> Spec
forall t.
(Arbitrary t, HasEqAsymmetric (MulType t t) t,
HasEqAsymmetric (MulType t t) (MulType t t),
HasEqAsymmetric
(MulType t (MulType t t)) (MulType (MulType t t) t),
HasEqAsymmetric
(MulType t (AddType t t)) (AddType (MulType t t) (MulType t t)),
CanTestCertainly (EqCompareType (MulType t t) t),
CanTestCertainly (EqCompareType (MulType t t) (MulType t t)),
CanTestCertainly
(EqCompareType
(MulType t (MulType t t)) (MulType (MulType t t) t)),
CanTestCertainly
(EqCompareType
(MulType t (AddType t t)) (AddType (MulType t t) (MulType t t))),
Show t, Show (MulType t t), Show (MulType t (MulType t t)),
Show (MulType (MulType t t) t), Show (MulType t (AddType t t)),
Show (AddType (MulType t t) (MulType t t)), CanAddAsymmetric t t,
CanAddAsymmetric (MulType t t) (MulType t t),
CanMulAsymmetric (MulType t t) t, CanMulAsymmetric t t,
CanMulAsymmetric t (MulType t t), CanMulAsymmetric t (AddType t t),
ConvertibleExactly Integer t) =>
T t -> Spec
specCanMulNotMixed T Dyadic
tDyadic
T Dyadic -> Spec
forall t.
(Show t, ConvertibleExactly Integer t,
CanTestCertainly (EqCompareType t t), HasEqAsymmetric t t,
CanMulAsymmetric t t, MulType t t ~ t) =>
T t -> Spec
specCanMulSameType T Dyadic
tDyadic
T Int -> T Dyadic -> T Integer -> Spec
forall t1 t2 t3.
(Arbitrary t1, Arbitrary t2, Arbitrary t3,
HasEqAsymmetric (MulType t1 t2) t1,
HasEqAsymmetric (MulType t1 t2) (MulType t2 t1),
HasEqAsymmetric
(MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3),
HasEqAsymmetric
(MulType t1 (AddType t2 t3))
(AddType (MulType t1 t2) (MulType t1 t3)),
CanTestCertainly (EqCompareType (MulType t1 t2) t1),
CanTestCertainly (EqCompareType (MulType t1 t2) (MulType t2 t1)),
CanTestCertainly
(EqCompareType
(MulType t1 (MulType t2 t3)) (MulType (MulType t1 t2) t3)),
CanTestCertainly
(EqCompareType
(MulType t1 (AddType t2 t3))
(AddType (MulType t1 t2) (MulType t1 t3))),
Show t1, Show (MulType t1 t2), Show t2, Show (MulType t2 t1),
Show t3, Show (MulType t1 (MulType t2 t3)),
Show (MulType (MulType t1 t2) t3),
Show (MulType t1 (AddType t2 t3)),
Show (AddType (MulType t1 t2) (MulType t1 t3)),
CanAddAsymmetric t2 t3,
CanAddAsymmetric (MulType t1 t2) (MulType t1 t3),
CanMulAsymmetric t2 t1, CanMulAsymmetric t2 t3,
CanMulAsymmetric (MulType t1 t2) t3, CanMulAsymmetric t1 t2,
CanMulAsymmetric t1 (MulType t2 t3),
CanMulAsymmetric t1 (AddType t2 t3), CanMulAsymmetric t1 t3,
ConvertibleExactly Integer t2) =>
T t1 -> T t2 -> T t3 -> Spec
specCanMul T Int
tInt T Dyadic
tDyadic T Integer
tInteger
String -> Property -> SpecWith (Arg Property)
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"Dyadic * Rational (dyadic only)" (Property -> SpecWith (Arg Property))
-> Property -> SpecWith (Arg Property)
forall a b. (a -> b) -> a -> b
$ do
(Dyadic -> Dyadic -> Bool) -> Property
forall prop. Testable prop => prop -> Property
property ((Dyadic -> Dyadic -> Bool) -> Property)
-> (Dyadic -> Dyadic -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \ (Dyadic
x :: Dyadic) (Dyadic
y :: Dyadic) ->
Dyadic
x Dyadic -> Dyadic -> MulType Dyadic Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* Dyadic
y Dyadic -> Rational -> EqCompareType Dyadic Rational
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Dyadic
x Dyadic -> Rational -> MulType Dyadic Rational
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
* (Dyadic -> Rational
forall t. CanBeRational t => t -> Rational
rational Dyadic
y)
T Dyadic -> T Integer -> Spec
forall t1 t2.
(Arbitrary t1, Arbitrary t2, CanTestPosNeg t2,
HasEqAsymmetric (PowType t1 t2) t1,
HasEqAsymmetric
(MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer)),
CanTestCertainly (EqCompareType (PowType t1 t2) t1),
CanTestCertainly
(EqCompareType
(MulType t1 (PowType t1 t2)) (PowType t1 (AddType t2 Integer))),
Show t1, Show (PowType t1 t2), Show t2,
Show (MulType t1 (PowType t1 t2)),
Show (PowType t1 (AddType t2 Integer)),
CanMulAsymmetric t1 (PowType t1 t2), CanPow t1 t2,
CanPow t1 (AddType t2 Integer), CanAddAsymmetric t2 Integer,
ConvertibleExactly Integer t1, ConvertibleExactly Integer t2) =>
T t1 -> T t2 -> Spec
specCanPow T Dyadic
tDyadic T Integer
tInteger
instance P.Num Dyadic where
fromInteger :: Integer -> Dyadic
fromInteger = Integer -> Dyadic
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> t2
convertExactly
negate :: Dyadic -> Dyadic
negate = Dyadic -> Dyadic
forall t. CanNeg t => t -> NegType t
negate
+ :: Dyadic -> Dyadic -> Dyadic
(+) = Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanAddAsymmetric t1 t2 => t1 -> t2 -> AddType t1 t2
(+)
* :: Dyadic -> Dyadic -> Dyadic
(*) = Dyadic -> Dyadic -> Dyadic
forall t1 t2. CanMulAsymmetric t1 t2 => t1 -> t2 -> MulType t1 t2
(*)
abs :: Dyadic -> Dyadic
abs = Dyadic -> Dyadic
forall t. CanAbs t => t -> AbsType t
abs
signum :: Dyadic -> Dyadic
signum Dyadic
d
| Dyadic
d Dyadic -> Integer -> OrderCompareType Dyadic Integer
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
< Integer
0 = Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic (-Integer
1)
| Dyadic
d Dyadic -> Integer -> EqCompareType Dyadic Integer
forall a b. HasEqAsymmetric a b => a -> b -> EqCompareType a b
== Integer
0 = Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Integer
0
| Bool
otherwise = Integer -> Dyadic
forall t. CanBeDyadic t => t -> Dyadic
dyadic Integer
1
instance P.Real Dyadic where
toRational :: Dyadic -> Rational
toRational = Dyadic -> Rational
forall t1 t2. ConvertibleExactly t1 t2 => t1 -> t2
convertExactly