{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{- |
A wrapper that provides instances of Haskell 98 and NumericPrelude
numeric type classes
for types that have NumericPrelude instances.
-}
module MathObj.Wrapper.NumericPrelude where

import qualified Algebra.Absolute as Absolute
import qualified Algebra.Additive as Additive
import qualified Algebra.Algebraic as Algebraic
import qualified Algebra.Field as Field
import qualified Algebra.FloatingPoint as Float
import qualified Algebra.IntegralDomain as Integral
import qualified Algebra.PrincipalIdealDomain as PID
import qualified Algebra.RealField as RealField
import qualified Algebra.RealIntegral as RealIntegral
import qualified Algebra.RealRing as RealRing
import qualified Algebra.RealTranscendental as RealTrans
import qualified Algebra.Ring as Ring
import qualified Algebra.ToInteger as ToInteger
import qualified Algebra.ToRational as ToRational
import qualified Algebra.Transcendental as Trans
import qualified Algebra.Units as Units
import qualified Algebra.ZeroTestable as ZeroTestable

import qualified Algebra.NormedSpace.Euclidean as NormEuc
import qualified Algebra.NormedSpace.Maximum as NormMax
import qualified Algebra.NormedSpace.Sum as NormSum
import qualified Algebra.OccasionallyScalar as OccScalar
import qualified Algebra.Differential as Differential
import qualified Algebra.DivisibleSpace as Divisible
import qualified Algebra.VectorSpace as VectorSpace
import qualified Algebra.Module as Module

import qualified Number.Ratio as Ratio

import Data.Ix (Ix, )

import Data.Tuple.HT (mapPair, )


{- |
This makes a type usable with Haskell98 type classes
that was initially implemented for NumericPrelude typeclasses.
E.g. if @a@ is in class 'Ring.C',
then @T a@ is both in class 'Num' and in 'Ring.C'.

You can even lift container types.
If @Polynomial a@ is in 'Ring.C' for all types @a@ that are in 'Ring.C',
then @T (Polynomial (MathObj.Wrapper.Haskell98.T a))@
is in 'Num' for all types @a@ that are in 'Num'.
-}
newtype T a = Cons {T a -> a
decons :: a}
   deriving
      (Int -> T a -> ShowS
[T a] -> ShowS
T a -> String
(Int -> T a -> ShowS)
-> (T a -> String) -> ([T a] -> ShowS) -> Show (T a)
forall a. Show a => Int -> T a -> ShowS
forall a. Show a => [T a] -> ShowS
forall a. Show a => T a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [T a] -> ShowS
$cshowList :: forall a. Show a => [T a] -> ShowS
show :: T a -> String
$cshow :: forall a. Show a => T a -> String
showsPrec :: Int -> T a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> T a -> ShowS
Show, T a -> T a -> Bool
(T a -> T a -> Bool) -> (T a -> T a -> Bool) -> Eq (T a)
forall a. Eq a => T a -> T a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: T a -> T a -> Bool
$c/= :: forall a. Eq a => T a -> T a -> Bool
== :: T a -> T a -> Bool
$c== :: forall a. Eq a => T a -> T a -> Bool
Eq, Eq (T a)
Eq (T a)
-> (T a -> T a -> Ordering)
-> (T a -> T a -> Bool)
-> (T a -> T a -> Bool)
-> (T a -> T a -> Bool)
-> (T a -> T a -> Bool)
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> Ord (T a)
T a -> T a -> Bool
T a -> T a -> Ordering
T a -> T a -> T a
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
forall a. Ord a => Eq (T a)
forall a. Ord a => T a -> T a -> Bool
forall a. Ord a => T a -> T a -> Ordering
forall a. Ord a => T a -> T a -> T a
min :: T a -> T a -> T a
$cmin :: forall a. Ord a => T a -> T a -> T a
max :: T a -> T a -> T a
$cmax :: forall a. Ord a => T a -> T a -> T a
>= :: T a -> T a -> Bool
$c>= :: forall a. Ord a => T a -> T a -> Bool
> :: T a -> T a -> Bool
$c> :: forall a. Ord a => T a -> T a -> Bool
<= :: T a -> T a -> Bool
$c<= :: forall a. Ord a => T a -> T a -> Bool
< :: T a -> T a -> Bool
$c< :: forall a. Ord a => T a -> T a -> Bool
compare :: T a -> T a -> Ordering
$ccompare :: forall a. Ord a => T a -> T a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (T a)
Ord, Ord (T a)
Ord (T a)
-> ((T a, T a) -> [T a])
-> ((T a, T a) -> T a -> Int)
-> ((T a, T a) -> T a -> Int)
-> ((T a, T a) -> T a -> Bool)
-> ((T a, T a) -> Int)
-> ((T a, T a) -> Int)
-> Ix (T a)
(T a, T a) -> Int
(T a, T a) -> [T a]
(T a, T a) -> T a -> Bool
(T a, T a) -> T a -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall a. Ix a => Ord (T a)
forall a. Ix a => (T a, T a) -> Int
forall a. Ix a => (T a, T a) -> [T a]
forall a. Ix a => (T a, T a) -> T a -> Bool
forall a. Ix a => (T a, T a) -> T a -> Int
unsafeRangeSize :: (T a, T a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (T a, T a) -> Int
rangeSize :: (T a, T a) -> Int
$crangeSize :: forall a. Ix a => (T a, T a) -> Int
inRange :: (T a, T a) -> T a -> Bool
$cinRange :: forall a. Ix a => (T a, T a) -> T a -> Bool
unsafeIndex :: (T a, T a) -> T a -> Int
$cunsafeIndex :: forall a. Ix a => (T a, T a) -> T a -> Int
index :: (T a, T a) -> T a -> Int
$cindex :: forall a. Ix a => (T a, T a) -> T a -> Int
range :: (T a, T a) -> [T a]
$crange :: forall a. Ix a => (T a, T a) -> [T a]
$cp1Ix :: forall a. Ix a => Ord (T a)
Ix, T a
T a -> T a -> Bounded (T a)
forall a. a -> a -> Bounded a
forall a. Bounded a => T a
maxBound :: T a
$cmaxBound :: forall a. Bounded a => T a
minBound :: T a
$cminBound :: forall a. Bounded a => T a
Bounded, Int -> T a
T a -> Int
T a -> [T a]
T a -> T a
T a -> T a -> [T a]
T a -> T a -> T a -> [T a]
(T a -> T a)
-> (T a -> T a)
-> (Int -> T a)
-> (T a -> Int)
-> (T a -> [T a])
-> (T a -> T a -> [T a])
-> (T a -> T a -> [T a])
-> (T a -> T a -> T a -> [T a])
-> Enum (T a)
forall a. Enum a => Int -> T a
forall a. Enum a => T a -> Int
forall a. Enum a => T a -> [T a]
forall a. Enum a => T a -> T a
forall a. Enum a => T a -> T a -> [T a]
forall a. Enum a => T a -> T a -> T a -> [T a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: T a -> T a -> T a -> [T a]
$cenumFromThenTo :: forall a. Enum a => T a -> T a -> T a -> [T a]
enumFromTo :: T a -> T a -> [T a]
$cenumFromTo :: forall a. Enum a => T a -> T a -> [T a]
enumFromThen :: T a -> T a -> [T a]
$cenumFromThen :: forall a. Enum a => T a -> T a -> [T a]
enumFrom :: T a -> [T a]
$cenumFrom :: forall a. Enum a => T a -> [T a]
fromEnum :: T a -> Int
$cfromEnum :: forall a. Enum a => T a -> Int
toEnum :: Int -> T a
$ctoEnum :: forall a. Enum a => Int -> T a
pred :: T a -> T a
$cpred :: forall a. Enum a => T a -> T a
succ :: T a -> T a
$csucc :: forall a. Enum a => T a -> T a
Enum,
       C (T a)
T a
Integer -> T a
C (T a)
-> (T a -> T a -> T a)
-> T a
-> (Integer -> T a)
-> (T a -> Integer -> T a)
-> C (T a)
T a -> Integer -> T a
T a -> T a -> T a
forall a.
C a
-> (a -> a -> a)
-> a
-> (Integer -> a)
-> (a -> Integer -> a)
-> C a
forall a. C a => C (T a)
forall a. C a => T a
forall a. C a => Integer -> T a
forall a. C a => T a -> Integer -> T a
forall a. C a => T a -> T a -> T a
^ :: T a -> Integer -> T a
$c^ :: forall a. C a => T a -> Integer -> T a
fromInteger :: Integer -> T a
$cfromInteger :: forall a. C a => Integer -> T a
one :: T a
$cone :: forall a. C a => T a
* :: T a -> T a -> T a
$c* :: forall a. C a => T a -> T a -> T a
$cp1C :: forall a. C a => C (T a)
Ring.C, T a
T a -> T a
T a -> T a -> T a
T a
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> (T a -> T a)
-> C (T a)
forall a. a -> (a -> a -> a) -> (a -> a -> a) -> (a -> a) -> C a
forall a. C a => T a
forall a. C a => T a -> T a
forall a. C a => T a -> T a -> T a
negate :: T a -> T a
$cnegate :: forall a. C a => T a -> T a
- :: T a -> T a -> T a
$c- :: forall a. C a => T a -> T a -> T a
+ :: T a -> T a -> T a
$c+ :: forall a. C a => T a -> T a -> T a
zero :: T a
$czero :: forall a. C a => T a
Additive.C, C (T a)
C (T a)
-> (T a -> T a -> T a)
-> (T a -> T a)
-> (Rational -> T a)
-> (T a -> Integer -> T a)
-> C (T a)
Rational -> T a
T a -> T a
T a -> Integer -> T a
T a -> T a -> T a
forall a.
C a
-> (a -> a -> a)
-> (a -> a)
-> (Rational -> a)
-> (a -> Integer -> a)
-> C a
forall a. C a => C (T a)
forall a. C a => Rational -> T a
forall a. C a => T a -> T a
forall a. C a => T a -> Integer -> T a
forall a. C a => T a -> T a -> T a
^- :: T a -> Integer -> T a
$c^- :: forall a. C a => T a -> Integer -> T a
fromRational' :: Rational -> T a
$cfromRational' :: forall a. C a => Rational -> T a
recip :: T a -> T a
$crecip :: forall a. C a => T a -> T a
/ :: T a -> T a -> T a
$c/ :: forall a. C a => T a -> T a -> T a
$cp1C :: forall a. C a => C (T a)
Field.C, C (T a)
Integer -> T a -> T a
C (T a)
-> (T a -> T a)
-> (Integer -> T a -> T a)
-> (T a -> Rational -> T a)
-> C (T a)
T a -> T a
T a -> Rational -> T a
forall a.
C a
-> (a -> a) -> (Integer -> a -> a) -> (a -> Rational -> a) -> C a
forall a. C a => C (T a)
forall a. C a => Integer -> T a -> T a
forall a. C a => T a -> T a
forall a. C a => T a -> Rational -> T a
^/ :: T a -> Rational -> T a
$c^/ :: forall a. C a => T a -> Rational -> T a
root :: Integer -> T a -> T a
$croot :: forall a. C a => Integer -> T a -> T a
sqrt :: T a -> T a
$csqrt :: forall a. C a => T a -> T a
$cp1C :: forall a. C a => C (T a)
Algebraic.C, C (T a)
T a
C (T a)
-> T a
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> C (T a)
T a -> T a
T a -> T a -> T a
forall a.
C a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> C a
forall a. C a => C (T a)
forall a. C a => T a
forall a. C a => T a -> T a
forall a. C a => T a -> T a -> T a
atanh :: T a -> T a
$catanh :: forall a. C a => T a -> T a
acosh :: T a -> T a
$cacosh :: forall a. C a => T a -> T a
asinh :: T a -> T a
$casinh :: forall a. C a => T a -> T a
tanh :: T a -> T a
$ctanh :: forall a. C a => T a -> T a
cosh :: T a -> T a
$ccosh :: forall a. C a => T a -> T a
sinh :: T a -> T a
$csinh :: forall a. C a => T a -> T a
atan :: T a -> T a
$catan :: forall a. C a => T a -> T a
acos :: T a -> T a
$cacos :: forall a. C a => T a -> T a
asin :: T a -> T a
$casin :: forall a. C a => T a -> T a
tan :: T a -> T a
$ctan :: forall a. C a => T a -> T a
cos :: T a -> T a
$ccos :: forall a. C a => T a -> T a
sin :: T a -> T a
$csin :: forall a. C a => T a -> T a
** :: T a -> T a -> T a
$c** :: forall a. C a => T a -> T a -> T a
logBase :: T a -> T a -> T a
$clogBase :: forall a. C a => T a -> T a -> T a
log :: T a -> T a
$clog :: forall a. C a => T a -> T a
exp :: T a -> T a
$cexp :: forall a. C a => T a -> T a
pi :: T a
$cpi :: forall a. C a => T a
$cp1C :: forall a. C a => C (T a)
Trans.C,
       C (T a)
C (T a)
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> (T a -> T a -> (T a, T a))
-> C (T a)
T a -> T a -> (T a, T a)
T a -> T a -> T a
forall a.
C a -> (a -> a -> a) -> (a -> a -> a) -> (a -> a -> (a, a)) -> C a
forall a. C a => C (T a)
forall a. C a => T a -> T a -> (T a, T a)
forall a. C a => T a -> T a -> T a
divMod :: T a -> T a -> (T a, T a)
$cdivMod :: forall a. C a => T a -> T a -> (T a, T a)
mod :: T a -> T a -> T a
$cmod :: forall a. C a => T a -> T a -> T a
div :: T a -> T a -> T a
$cdiv :: forall a. C a => T a -> T a -> T a
$cp1C :: forall a. C a => C (T a)
Integral.C, C (T a)
C (T a)
C (T a)
-> C (T a)
-> (T a -> T a -> (T a, (T a, T a)))
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> C (T a)
T a -> T a -> (T a, (T a, T a))
T a -> T a -> T a
forall a.
C a
-> C a
-> (a -> a -> (a, (a, a)))
-> (a -> a -> a)
-> (a -> a -> a)
-> C a
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => T a -> T a -> (T a, (T a, T a))
forall a. C a => T a -> T a -> T a
lcm :: T a -> T a -> T a
$clcm :: forall a. C a => T a -> T a -> T a
gcd :: T a -> T a -> T a
$cgcd :: forall a. C a => T a -> T a -> T a
extendedGCD :: T a -> T a -> (T a, (T a, T a))
$cextendedGCD :: forall a. C a => T a -> T a -> (T a, (T a, T a))
$cp2C :: forall a. C a => C (T a)
$cp1C :: forall a. C a => C (T a)
PID.C, C (T a)
C (T a)
-> (T a -> Bool)
-> (T a -> T a)
-> (T a -> T a)
-> (T a -> T a)
-> C (T a)
T a -> Bool
T a -> T a
forall a.
C a -> (a -> Bool) -> (a -> a) -> (a -> a) -> (a -> a) -> C a
forall a. C a => C (T a)
forall a. C a => T a -> Bool
forall a. C a => T a -> T a
stdUnitInv :: T a -> T a
$cstdUnitInv :: forall a. C a => T a -> T a
stdUnit :: T a -> T a
$cstdUnit :: forall a. C a => T a -> T a
stdAssociate :: T a -> T a
$cstdAssociate :: forall a. C a => T a -> T a
isUnit :: T a -> Bool
$cisUnit :: forall a. C a => T a -> Bool
$cp1C :: forall a. C a => C (T a)
Units.C,
       C (T a)
C (T a) -> (T a -> T a) -> (T a -> T a) -> C (T a)
T a -> T a
forall a. C a -> (a -> a) -> (a -> a) -> C a
forall a. C a => C (T a)
forall a. C a => T a -> T a
signum :: T a -> T a
$csignum :: forall a. C a => T a -> T a
abs :: T a -> T a
$cabs :: forall a. C a => T a -> T a
$cp1C :: forall a. C a => C (T a)
Absolute.C, T a -> Bool
(T a -> Bool) -> C (T a)
forall a. C a => T a -> Bool
forall a. (a -> Bool) -> C a
isZero :: T a -> Bool
$cisZero :: forall a. C a => T a -> Bool
ZeroTestable.C,
       C (T a)
C (T a)
C (T a) -> C (T a) -> C (T a)
forall a. (C a, C a) => C (T a)
forall a. (C a, C a) => C (T a)
forall a. C a -> C a -> C a
$cp2C :: forall a. (C a, C a) => C (T a)
$cp1C :: forall a. (C a, C a) => C (T a)
RealField.C, Ord (T a)
C (T a)
C (T a)
C (T a)
C (T a)
-> C (T a)
-> Ord (T a)
-> C (T a)
-> (T a -> T a -> T a)
-> (T a -> T a -> T a)
-> (T a -> T a -> (T a, T a))
-> C (T a)
T a -> T a -> (T a, T a)
T a -> T a -> T a
forall a.
C a
-> C a
-> Ord a
-> C a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> C a
forall a. C a => Ord (T a)
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => T a -> T a -> (T a, T a)
forall a. C a => T a -> T a -> T a
quotRem :: T a -> T a -> (T a, T a)
$cquotRem :: forall a. C a => T a -> T a -> (T a, T a)
rem :: T a -> T a -> T a
$crem :: forall a. C a => T a -> T a -> T a
quot :: T a -> T a -> T a
$cquot :: forall a. C a => T a -> T a -> T a
$cp4C :: forall a. C a => C (T a)
$cp3C :: forall a. C a => Ord (T a)
$cp2C :: forall a. C a => C (T a)
$cp1C :: forall a. C a => C (T a)
RealIntegral.C, Ord (T a)
C (T a)
C (T a)
-> Ord (T a)
-> (forall b. C b => T a -> (b, T a))
-> (T a -> T a)
-> (forall b. C b => T a -> b)
-> (forall b. C b => T a -> b)
-> (forall b. C b => T a -> b)
-> (forall b. C b => T a -> b)
-> C (T a)
T a -> b
T a -> b
T a -> b
T a -> b
T a -> (b, T a)
T a -> T a
forall b. C b => T a -> b
forall b. C b => T a -> (b, T a)
forall a.
C a
-> Ord a
-> (forall b. C b => a -> (b, a))
-> (a -> a)
-> (forall b. C b => a -> b)
-> (forall b. C b => a -> b)
-> (forall b. C b => a -> b)
-> (forall b. C b => a -> b)
-> C a
forall b. C b => T a -> b
forall a. C a => Ord (T a)
forall a. C a => C (T a)
forall a. C a => T a -> T a
forall a b. (C a, C b) => T a -> b
forall a b. (C a, C b) => T a -> (b, T a)
forall a b. (C a, C b) => T a -> b
round :: T a -> b
$cround :: forall a b. (C a, C b) => T a -> b
truncate :: T a -> b
$ctruncate :: forall a b. (C a, C b) => T a -> b
floor :: T a -> b
$cfloor :: forall a b. (C a, C b) => T a -> b
ceiling :: T a -> b
$cceiling :: forall a b. (C a, C b) => T a -> b
fraction :: T a -> T a
$cfraction :: forall a. C a => T a -> T a
splitFraction :: T a -> (b, T a)
$csplitFraction :: forall a b. (C a, C b) => T a -> (b, T a)
$cp2C :: forall a. C a => Ord (T a)
$cp1C :: forall a. C a => C (T a)
RealRing.C, C (T a)
C (T a)
C (T a) -> C (T a) -> (T a -> T a -> T a) -> C (T a)
T a -> T a -> T a
forall a. C a -> C a -> (a -> a -> a) -> C a
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => T a -> T a -> T a
atan2 :: T a -> T a -> T a
$catan2 :: forall a. C a => T a -> T a -> T a
$cp2C :: forall a. C a => C (T a)
$cp1C :: forall a. C a => C (T a)
RealTrans.C,
       C (T a)
C (T a)
C (T a) -> C (T a) -> (T a -> Integer) -> C (T a)
T a -> Integer
forall a. C a -> C a -> (a -> Integer) -> C a
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => T a -> Integer
toInteger :: T a -> Integer
$ctoInteger :: forall a. C a => T a -> Integer
$cp2C :: forall a. C a => C (T a)
$cp1C :: forall a. C a => C (T a)
ToInteger.C, Ord (T a)
C (T a)
C (T a)
C (T a) -> C (T a) -> Ord (T a) -> (T a -> Rational) -> C (T a)
T a -> Rational
forall a. C a -> C a -> Ord a -> (a -> Rational) -> C a
forall a. C a => Ord (T a)
forall a. C a => C (T a)
forall a. C a => C (T a)
forall a. C a => T a -> Rational
toRational :: T a -> Rational
$ctoRational :: forall a. C a => T a -> Rational
$cp3C :: forall a. C a => Ord (T a)
$cp2C :: forall a. C a => C (T a)
$cp1C :: forall a. C a => C (T a)
ToRational.C, C (T a)
Int -> T a -> T a
Integer -> Int -> T a
C (T a)
-> (T a -> Integer)
-> (T a -> Int)
-> (T a -> (Int, Int))
-> (T a -> (Integer, Int))
-> (Integer -> Int -> T a)
-> (T a -> Int)
-> (T a -> T a)
-> (Int -> T a -> T a)
-> (T a -> Bool)
-> (T a -> Bool)
-> (T a -> Bool)
-> (T a -> Bool)
-> (T a -> Bool)
-> C (T a)
T a -> Bool
T a -> Int
T a -> Integer
T a -> (Int, Int)
T a -> (Integer, Int)
T a -> T a
forall a.
C a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> C a
forall a. C a => C (T a)
forall a. C a => Int -> T a -> T a
forall a. C a => Integer -> Int -> T a
forall a. C a => T a -> Bool
forall a. C a => T a -> Int
forall a. C a => T a -> Integer
forall a. C a => T a -> (Int, Int)
forall a. C a => T a -> (Integer, Int)
forall a. C a => T a -> T a
isIEEE :: T a -> Bool
$cisIEEE :: forall a. C a => T a -> Bool
isNegativeZero :: T a -> Bool
$cisNegativeZero :: forall a. C a => T a -> Bool
isDenormalized :: T a -> Bool
$cisDenormalized :: forall a. C a => T a -> Bool
isInfinite :: T a -> Bool
$cisInfinite :: forall a. C a => T a -> Bool
isNaN :: T a -> Bool
$cisNaN :: forall a. C a => T a -> Bool
scale :: Int -> T a -> T a
$cscale :: forall a. C a => Int -> T a -> T a
significand :: T a -> T a
$csignificand :: forall a. C a => T a -> T a
exponent :: T a -> Int
$cexponent :: forall a. C a => T a -> Int
encode :: Integer -> Int -> T a
$cencode :: forall a. C a => Integer -> Int -> T a
decode :: T a -> (Integer, Int)
$cdecode :: forall a. C a => T a -> (Integer, Int)
range :: T a -> (Int, Int)
$crange :: forall a. C a => T a -> (Int, Int)
digits :: T a -> Int
$cdigits :: forall a. C a => T a -> Int
radix :: T a -> Integer
$cradix :: forall a. C a => T a -> Integer
$cp1C :: forall a. C a => C (T a)
Float.C,
       C (T a)
C (T a) -> (T a -> T a) -> C (T a)
T a -> T a
forall a. C a -> (a -> a) -> C a
forall a. C a => C (T a)
forall a. C a => T a -> T a
differentiate :: T a -> T a
$cdifferentiate :: forall a. C a => T a -> T a
$cp1C :: forall a. C a => C (T a)
Differential.C)

{-# INLINE lift1 #-}
lift1 :: (a -> b) -> T a -> T b
lift1 :: (a -> b) -> T a -> T b
lift1 a -> b
f (Cons a
a) = b -> T b
forall a. a -> T a
Cons (a -> b
f a
a)

{-# INLINE lift2 #-}
lift2 :: (a -> b -> c) -> T a -> T b -> T c
lift2 :: (a -> b -> c) -> T a -> T b -> T c
lift2 a -> b -> c
f (Cons a
a) (Cons b
b) = c -> T c
forall a. a -> T a
Cons (a -> b -> c
f a
a b
b)


instance Functor T where
   {-# INLINE fmap #-}
   fmap :: (a -> b) -> T a -> T b
fmap a -> b
f (Cons a
a) = b -> T b
forall a. a -> T a
Cons (a -> b
f a
a)


{-
instance Enum a => Enum (T a) where
   succ (Cons n) = Cons (succ n)
   pred (Cons n) = Cons (pred n)
   toEnum n = Cons (toEnum n)
   fromEnum (Cons n) = fromEnum n
   enumFrom (Cons n) =
      map Cons (enumFrom n)
   enumFromThen (Cons n) (Cons m) =
      map Cons (enumFromThen n m)
   enumFromTo (Cons n) (Cons m) =
      map Cons (enumFromTo n m)
   enumFromThenTo (Cons n) (Cons m) (Cons p) =
      map Cons (enumFromThenTo n m p)
-}

instance (Ring.C a, Absolute.C a, Eq a, Show a) => Num (T a) where
   + :: T a -> T a -> T a
(+) = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
(Additive.+)
   (-) = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
(Additive.-)
   negate :: T a -> T a
negate = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Additive.negate

   fromInteger :: Integer -> T a
fromInteger = a -> T a
forall a. a -> T a
Cons (a -> T a) -> (Integer -> a) -> Integer -> T a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. C a => Integer -> a
Ring.fromInteger
   * :: T a -> T a -> T a
(*) = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
(Ring.*)

   abs :: T a -> T a
abs = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Absolute.abs
   signum :: T a -> T a
signum = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Absolute.signum

instance (RealIntegral.C a, Absolute.C a, ToInteger.C a, Ord a, Enum a, Show a) => Integral (T a) where
   quot :: T a -> T a -> T a
quot = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
RealIntegral.quot
   rem :: T a -> T a -> T a
rem = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
RealIntegral.rem
   quotRem :: T a -> T a -> (T a, T a)
quotRem (Cons a
a) (Cons a
b) =
      (a -> T a, a -> T a) -> (a, a) -> (T a, T a)
forall a c b d. (a -> c, b -> d) -> (a, b) -> (c, d)
mapPair (a -> T a
forall a. a -> T a
Cons, a -> T a
forall a. a -> T a
Cons) (a -> a -> (a, a)
forall a. C a => a -> a -> (a, a)
RealIntegral.quotRem a
a a
b)
   div :: T a -> T a -> T a
div = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
Integral.div
   mod :: T a -> T a -> T a
mod = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
Integral.mod
   divMod :: T a -> T a -> (T a, T a)
divMod (Cons a
a) (Cons a
b) =
      (a -> T a, a -> T a) -> (a, a) -> (T a, T a)
forall a c b d. (a -> c, b -> d) -> (a, b) -> (c, d)
mapPair (a -> T a
forall a. a -> T a
Cons, a -> T a
forall a. a -> T a
Cons) (a -> a -> (a, a)
forall a. C a => a -> a -> (a, a)
Integral.divMod a
a a
b)
   toInteger :: T a -> Integer
toInteger (Cons a
a) = a -> Integer
forall a. C a => a -> Integer
ToInteger.toInteger a
a

instance (Field.C a, Absolute.C a, Eq a, Show a) => Fractional (T a) where
   / :: T a -> T a -> T a
(/) = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
(Field./)
   recip :: T a -> T a
recip = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Field.recip
   fromRational :: Rational -> T a
fromRational = a -> T a
forall a. a -> T a
Cons (a -> T a) -> (Rational -> a) -> Rational -> T a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> a
forall a. C a => Rational -> a
Field.fromRational

instance (Trans.C a, Absolute.C a, Eq a, Show a) => Floating (T a) where
   sqrt :: T a -> T a
sqrt    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Algebraic.sqrt
   pi :: T a
pi      = a -> T a
forall a. a -> T a
Cons a
forall a. C a => a
Trans.pi
   log :: T a -> T a
log     = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.log
   exp :: T a -> T a
exp     = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.exp
   logBase :: T a -> T a -> T a
logBase = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
Trans.logBase
   ** :: T a -> T a -> T a
(**)    = (a -> a -> a) -> T a -> T a -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> a -> a
forall a. C a => a -> a -> a
(Trans.**)
   cos :: T a -> T a
cos     = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.cos
   tan :: T a -> T a
tan     = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.tan
   sin :: T a -> T a
sin     = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.sin
   acos :: T a -> T a
acos    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.acos
   atan :: T a -> T a
atan    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.atan
   asin :: T a -> T a
asin    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.asin
   cosh :: T a -> T a
cosh    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.cosh
   tanh :: T a -> T a
tanh    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.tanh
   sinh :: T a -> T a
sinh    = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.sinh
   acosh :: T a -> T a
acosh   = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.acosh
   atanh :: T a -> T a
atanh   = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.atanh
   asinh :: T a -> T a
asinh   = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Trans.asinh

instance (ToRational.C a, Absolute.C a, Ord a, Show a) => Real (T a) where
   toRational :: T a -> Rational
toRational (Cons a
a) =
      Rational -> Rational
forall a. Integral a => T a -> Ratio a
Ratio.toRational98 (a -> Rational
forall a. C a => a -> Rational
ToRational.toRational a
a)

instance (Field.C a, RealRing.C a, ToRational.C a, Absolute.C a, Ord a, Show a) => RealFrac (T a) where
   properFraction :: T a -> (b, T a)
properFraction (Cons a
a) =
      let b :: Integer
b = a -> Integer
forall a b. (C a, C b) => a -> b
RealRing.truncate a
a
      in  (Integer -> b
forall a. Num a => Integer -> a
fromInteger Integer
b, a -> T a
forall a. a -> T a
Cons (a
a a -> a -> a
forall a. C a => a -> a -> a
Additive.- Integer -> a
forall a. C a => Integer -> a
Ring.fromInteger Integer
b))
   ceiling :: T a -> b
ceiling (Cons a
a) = Integer -> b
forall a. Num a => Integer -> a
fromInteger (a -> Integer
forall a b. (C a, C b) => a -> b
RealRing.ceiling a
a)
   floor :: T a -> b
floor (Cons a
a) = Integer -> b
forall a. Num a => Integer -> a
fromInteger (a -> Integer
forall a b. (C a, C b) => a -> b
RealRing.floor a
a)
   truncate :: T a -> b
truncate (Cons a
a) = Integer -> b
forall a. Num a => Integer -> a
fromInteger (a -> Integer
forall a b. (C a, C b) => a -> b
RealRing.truncate a
a)
   round :: T a -> b
round (Cons a
a) = Integer -> b
forall a. Num a => Integer -> a
fromInteger (a -> Integer
forall a b. (C a, C b) => a -> b
RealRing.round a
a)

instance (RealTrans.C a, Float.C a, ToRational.C a, Absolute.C a, Ord a, Show a) => RealFloat (T a) where
   atan2 :: T a -> T a -> T a
atan2 = T a -> T a -> T a
forall a. C a => a -> a -> a
RealTrans.atan2
   floatRadix :: T a -> Integer
floatRadix = a -> Integer
forall a. C a => a -> Integer
Float.radix (a -> Integer) -> (T a -> a) -> T a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   floatDigits :: T a -> Int
floatDigits = a -> Int
forall a. C a => a -> Int
Float.digits (a -> Int) -> (T a -> a) -> T a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   floatRange :: T a -> (Int, Int)
floatRange = a -> (Int, Int)
forall a. C a => a -> (Int, Int)
Float.range (a -> (Int, Int)) -> (T a -> a) -> T a -> (Int, Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   decodeFloat :: T a -> (Integer, Int)
decodeFloat = a -> (Integer, Int)
forall a. C a => a -> (Integer, Int)
Float.decode (a -> (Integer, Int)) -> (T a -> a) -> T a -> (Integer, Int)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   encodeFloat :: Integer -> Int -> T a
encodeFloat Integer
m = a -> T a
forall a. a -> T a
Cons (a -> T a) -> (Int -> a) -> Int -> T a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Int -> a
forall a. C a => Integer -> Int -> a
Float.encode Integer
m
   exponent :: T a -> Int
exponent = a -> Int
forall a. C a => a -> Int
Float.exponent (a -> Int) -> (T a -> a) -> T a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   significand :: T a -> T a
significand = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 a -> a
forall a. C a => a -> a
Float.significand
   scaleFloat :: Int -> T a -> T a
scaleFloat = (a -> a) -> T a -> T a
forall a b. (a -> b) -> T a -> T b
lift1 ((a -> a) -> T a -> T a) -> (Int -> a -> a) -> Int -> T a -> T a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> a
forall a. C a => Int -> a -> a
Float.scale
   isNaN :: T a -> Bool
isNaN = a -> Bool
forall a. C a => a -> Bool
Float.isNaN (a -> Bool) -> (T a -> a) -> T a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   isInfinite :: T a -> Bool
isInfinite = a -> Bool
forall a. C a => a -> Bool
Float.isInfinite (a -> Bool) -> (T a -> a) -> T a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   isDenormalized :: T a -> Bool
isDenormalized = a -> Bool
forall a. C a => a -> Bool
Float.isDenormalized (a -> Bool) -> (T a -> a) -> T a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   isNegativeZero :: T a -> Bool
isNegativeZero = a -> Bool
forall a. C a => a -> Bool
Float.isNegativeZero (a -> Bool) -> (T a -> a) -> T a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons
   isIEEE :: T a -> Bool
isIEEE = a -> Bool
forall a. C a => a -> Bool
Float.isIEEE (a -> Bool) -> (T a -> a) -> T a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. T a -> a
forall a. T a -> a
decons

{-
instance Additive.C (T a) where
instance Ring.C (T a) where
instance Field.C (T a) where
instance Algebraic.C (T a) where
instance Trans.C (T a) where

instance Units.C (T a) where
instance Integral.C (T a) where
instance PID.C (T a) where

instance ZeroTestable.C (T a) where
instance Absolute.C (T a) where
instance (Ord a) => RealField.C (T a) where
instance (Ord a) => RealIntegral.C (T a) where
instance (Ord a) => RealRing.C (T a) where
instance (Ord a) => RealTrans.C (T a) where

instance (Ord a) => ToInteger.C (T a) where
instance (Ord a) => ToRational.C (T a) where
-}

instance Module.C a v => Module.C (T a) (T v) where
   *> :: T a -> T v -> T v
(*>) = (a -> v -> v) -> T a -> T v -> T v
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 a -> v -> v
forall a v. C a v => a -> v -> v
(Module.*>)

instance VectorSpace.C a v => VectorSpace.C (T a) (T v) where

instance Divisible.C a v => Divisible.C (T a) (T v) where
   </> :: T v -> T v -> T a
(</>) = (v -> v -> a) -> T v -> T v -> T a
forall a b c. (a -> b -> c) -> T a -> T b -> T c
lift2 v -> v -> a
forall a b. C a b => b -> b -> a
(Divisible.</>)

instance OccScalar.C a v => OccScalar.C (T a) (T v) where
   toScalar :: T v -> T a
toScalar = (v -> a) -> T v -> T a
forall a b. (a -> b) -> T a -> T b
lift1 v -> a
forall a v. C a v => v -> a
OccScalar.toScalar
   toMaybeScalar :: T v -> Maybe (T a)
toMaybeScalar (Cons v
a) = (a -> T a) -> Maybe a -> Maybe (T a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> T a
forall a. a -> T a
Cons (v -> Maybe a
forall a v. C a v => v -> Maybe a
OccScalar.toMaybeScalar v
a)
   fromScalar :: T a -> T v
fromScalar = (a -> v) -> T a -> T v
forall a b. (a -> b) -> T a -> T b
lift1 a -> v
forall a v. C a v => a -> v
OccScalar.fromScalar

instance NormEuc.Sqr a v => NormEuc.Sqr (T a) (T v) where
   normSqr :: T v -> T a
normSqr = (v -> a) -> T v -> T a
forall a b. (a -> b) -> T a -> T b
lift1 v -> a
forall a v. Sqr a v => v -> a
NormEuc.normSqr

instance NormEuc.C a v => NormEuc.C (T a) (T v) where
   norm :: T v -> T a
norm = (v -> a) -> T v -> T a
forall a b. (a -> b) -> T a -> T b
lift1 v -> a
forall a v. C a v => v -> a
NormEuc.norm

instance NormMax.C a v => NormMax.C (T a) (T v) where
   norm :: T v -> T a
norm = (v -> a) -> T v -> T a
forall a b. (a -> b) -> T a -> T b
lift1 v -> a
forall a v. C a v => v -> a
NormMax.norm

instance NormSum.C a v => NormSum.C (T a) (T v) where
   norm :: T v -> T a
norm = (v -> a) -> T v -> T a
forall a b. (a -> b) -> T a -> T b
lift1 v -> a
forall a v. C a v => v -> a
NormSum.norm


unimplemented :: String -> a
unimplemented :: String -> a
unimplemented String
name =
   String -> a
forall a. HasCallStack => String -> a
error (String
name String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"cannot be implemented in terms of NumericPrelude type classes")