{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
module AERN2.MP.WithCurrentPrec
(
WithCurrentPrec(..), runWithPrec, HasCurrentPrecision(..)
, WithAnyPrec(..)
)
where
import qualified MixedTypesNumPrelude as MxP
import Prelude
import Numeric.CollectErrors (CN, cn, NumErrors, CanTakeErrors(..))
import Data.Proxy
import Data.Reflection
import GHC.TypeLits
import AERN2.Limit
import AERN2.MP.Precision
import AERN2.MP.Ball
class HasCurrentPrecision p where
getCurrentPrecision :: proxy p -> Precision
instance KnownNat n => HasCurrentPrecision n where
getCurrentPrecision :: proxy n -> Precision
getCurrentPrecision proxy n
p = Precision -> Precision -> Precision
forall a. Ord a => a -> a -> a
max (Integer -> Precision
prec Integer
2) (Precision -> Precision)
-> (Precision -> Precision) -> Precision -> Precision
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Precision -> Precision -> Precision
forall a. Ord a => a -> a -> a
min Precision
maximumPrecision (Precision -> Precision) -> Precision -> Precision
forall a b. (a -> b) -> a -> b
$ Integer -> Precision
prec (proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal proxy n
p)
newtype WithAnyPrec t = WithAnyPrec (forall p. (KnownNat p) => WithCurrentPrec t p)
newtype WithCurrentPrec t p = WithCurrentPrec { WithCurrentPrec t p -> t
unWithCurrentPrec :: t }
deriving (Int -> WithCurrentPrec t p -> ShowS
[WithCurrentPrec t p] -> ShowS
WithCurrentPrec t p -> String
(Int -> WithCurrentPrec t p -> ShowS)
-> (WithCurrentPrec t p -> String)
-> ([WithCurrentPrec t p] -> ShowS)
-> Show (WithCurrentPrec t p)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall t k (p :: k). Show t => Int -> WithCurrentPrec t p -> ShowS
forall t k (p :: k). Show t => [WithCurrentPrec t p] -> ShowS
forall t k (p :: k). Show t => WithCurrentPrec t p -> String
showList :: [WithCurrentPrec t p] -> ShowS
$cshowList :: forall t k (p :: k). Show t => [WithCurrentPrec t p] -> ShowS
show :: WithCurrentPrec t p -> String
$cshow :: forall t k (p :: k). Show t => WithCurrentPrec t p -> String
showsPrec :: Int -> WithCurrentPrec t p -> ShowS
$cshowsPrec :: forall t k (p :: k). Show t => Int -> WithCurrentPrec t p -> ShowS
Show)
deriving instance (CanTakeErrors NumErrors t) => (CanTakeErrors NumErrors (WithCurrentPrec t p))
runWithPrec :: Precision -> (forall n. (KnownNat n) => WithCurrentPrec t n) -> t
runWithPrec :: Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec t n) -> t
runWithPrec Precision
p (wfp :: (forall n. (KnownNat n) => WithCurrentPrec t n)) =
Integer -> (forall (n :: Nat). KnownNat n => Proxy n -> t) -> t
forall r.
Integer -> (forall (n :: Nat). KnownNat n => Proxy n -> r) -> r
reifyNat (Precision -> Integer
forall t. CanBeInteger t => t -> Integer
MxP.integer Precision
p) forall (n :: Nat). KnownNat n => Proxy n -> t
withNat
where
withNat :: KnownNat n => Proxy n -> t
withNat :: Proxy n -> t
withNat (Proxy n
_ :: Proxy n) =
WithCurrentPrec t n -> t
forall t k (p :: k). WithCurrentPrec t p -> t
unWithCurrentPrec (WithCurrentPrec t n
forall (n :: Nat). KnownNat n => WithCurrentPrec t n
wfp :: WithCurrentPrec t n)
instance
(MxP.HasOrderAsymmetric t1 t2)
=>
MxP.HasOrderAsymmetric (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
where
type OrderCompareType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2) = MxP.OrderCompareType t1 t2
greaterThan :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> OrderCompareType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
greaterThan (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t1 -> t2 -> OrderCompareType t1 t2
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
MxP.greaterThan t1
v1 t2
v2
lessThan :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> OrderCompareType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
lessThan (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t1 -> t2 -> OrderCompareType t1 t2
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
MxP.lessThan t1
v1 t2
v2
geq :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> OrderCompareType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
geq (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t1 -> t2 -> OrderCompareType t1 t2
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
MxP.geq t1
v1 t2
v2
leq :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> OrderCompareType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
leq (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t1 -> t2 -> OrderCompareType t1 t2
forall a b.
HasOrderAsymmetric a b =>
a -> b -> OrderCompareType a b
MxP.leq t1
v1 t2
v2
instance
(MxP.CanMinMaxAsymmetric t1 t2, p1 ~ p2)
=>
MxP.CanMinMaxAsymmetric (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
where
type MinMaxType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2) = WithCurrentPrec (MxP.MinMaxType t1 t2) p1
min :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> MinMaxType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
min (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2)
-> MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2
forall a b. (a -> b) -> a -> b
$ t1 -> t2 -> MinMaxType t1 t2
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
MxP.min t1
v1 t2
v2
max :: WithCurrentPrec t1 p1
-> WithCurrentPrec t2 p2
-> MinMaxType (WithCurrentPrec t1 p1) (WithCurrentPrec t2 p2)
max (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2)
-> MinMaxType t1 t2 -> WithCurrentPrec (MinMaxType t1 t2) p2
forall a b. (a -> b) -> a -> b
$ t1 -> t2 -> MinMaxType t1 t2
forall t1 t2.
CanMinMaxAsymmetric t1 t2 =>
t1 -> t2 -> MinMaxType t1 t2
MxP.max t1
v1 t2
v2
instance Eq t => Eq (WithCurrentPrec t p) where
== :: WithCurrentPrec t p -> WithCurrentPrec t p -> Bool
(==) = (t -> t -> Bool)
-> WithCurrentPrec t p -> WithCurrentPrec t p -> Bool
forall k t1 t2 t3 (p :: k).
(t1 -> t2 -> t3)
-> WithCurrentPrec t1 p -> WithCurrentPrec t2 p -> t3
lift2P t -> t -> Bool
forall a. Eq a => a -> a -> Bool
(==)
instance Ord t => Ord (WithCurrentPrec t p) where
compare :: WithCurrentPrec t p -> WithCurrentPrec t p -> Ordering
compare = (t -> t -> Ordering)
-> WithCurrentPrec t p -> WithCurrentPrec t p -> Ordering
forall k t1 t2 t3 (p :: k).
(t1 -> t2 -> t3)
-> WithCurrentPrec t1 p -> WithCurrentPrec t2 p -> t3
lift2P t -> t -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
instance
(HasCurrentPrecision p, Num t, ConvertibleWithPrecision Integer t)
=>
Num (WithCurrentPrec t p)
where
fromInteger :: Integer -> WithCurrentPrec t p
fromInteger Integer
n = WithCurrentPrec t p
r
where
r :: WithCurrentPrec t p
r = t -> WithCurrentPrec t p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (t -> WithCurrentPrec t p) -> t -> WithCurrentPrec t p
forall a b. (a -> b) -> a -> b
$ Precision -> Integer -> t
forall t1 t2.
ConvertibleWithPrecision t1 t2 =>
Precision -> t1 -> t2
convertP (WithCurrentPrec t p -> Precision
forall k (p :: k) (proxy :: k -> *).
HasCurrentPrecision p =>
proxy p -> Precision
getCurrentPrecision WithCurrentPrec t p
r) Integer
n
negate :: WithCurrentPrec t p -> WithCurrentPrec t p
negate = (t -> t) -> WithCurrentPrec t p -> WithCurrentPrec t p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 t -> t
forall a. Num a => a -> a
negate
abs :: WithCurrentPrec t p -> WithCurrentPrec t p
abs = (t -> t) -> WithCurrentPrec t p -> WithCurrentPrec t p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 t -> t
forall a. Num a => a -> a
abs
+ :: WithCurrentPrec t p -> WithCurrentPrec t p -> WithCurrentPrec t p
(+) = (t -> t -> t)
-> WithCurrentPrec t p
-> WithCurrentPrec t p
-> WithCurrentPrec t p
forall k t1 t2 t3 (p :: k).
(t1 -> t2 -> t3)
-> WithCurrentPrec t1 p
-> WithCurrentPrec t2 p
-> WithCurrentPrec t3 p
lift2 t -> t -> t
forall a. Num a => a -> a -> a
(+)
* :: WithCurrentPrec t p -> WithCurrentPrec t p -> WithCurrentPrec t p
(*) = (t -> t -> t)
-> WithCurrentPrec t p
-> WithCurrentPrec t p
-> WithCurrentPrec t p
forall k t1 t2 t3 (p :: k).
(t1 -> t2 -> t3)
-> WithCurrentPrec t1 p
-> WithCurrentPrec t2 p
-> WithCurrentPrec t3 p
lift2 t -> t -> t
forall a. Num a => a -> a -> a
(*)
signum :: WithCurrentPrec t p -> WithCurrentPrec t p
signum = (t -> t) -> WithCurrentPrec t p -> WithCurrentPrec t p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 t -> t
forall a. Num a => a -> a
signum
instance
(HasCurrentPrecision p, Fractional t
, ConvertibleWithPrecision Integer t, ConvertibleWithPrecision Rational t)
=>
Fractional (WithCurrentPrec t p)
where
fromRational :: Rational -> WithCurrentPrec t p
fromRational Rational
q = WithCurrentPrec t p
r
where
r :: WithCurrentPrec t p
r = t -> WithCurrentPrec t p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (t -> WithCurrentPrec t p) -> t -> WithCurrentPrec t p
forall a b. (a -> b) -> a -> b
$ Precision -> Rational -> t
forall t1 t2.
ConvertibleWithPrecision t1 t2 =>
Precision -> t1 -> t2
convertP (WithCurrentPrec t p -> Precision
forall k (p :: k) (proxy :: k -> *).
HasCurrentPrecision p =>
proxy p -> Precision
getCurrentPrecision WithCurrentPrec t p
r) Rational
q
recip :: WithCurrentPrec t p -> WithCurrentPrec t p
recip = (t -> t) -> WithCurrentPrec t p -> WithCurrentPrec t p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 t -> t
forall a. Fractional a => a -> a
recip
/ :: WithCurrentPrec t p -> WithCurrentPrec t p -> WithCurrentPrec t p
(/) = (t -> t -> t)
-> WithCurrentPrec t p
-> WithCurrentPrec t p
-> WithCurrentPrec t p
forall k t1 t2 t3 (p :: k).
(t1 -> t2 -> t3)
-> WithCurrentPrec t1 p
-> WithCurrentPrec t2 p
-> WithCurrentPrec t3 p
lift2 t -> t -> t
forall a. Fractional a => a -> a -> a
(/)
instance (HasCurrentPrecision p) => Floating (WithCurrentPrec (CN MPBall) p) where
pi :: WithCurrentPrec (CN MPBall) p
pi = WithCurrentPrec (CN MPBall) p
r
where
r :: WithCurrentPrec (CN MPBall) p
r = CN MPBall -> WithCurrentPrec (CN MPBall) p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (CN MPBall -> WithCurrentPrec (CN MPBall) p)
-> CN MPBall -> WithCurrentPrec (CN MPBall) p
forall a b. (a -> b) -> a -> b
$ MPBall -> CN MPBall
forall v. v -> CN v
cn (MPBall -> CN MPBall) -> MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ Precision -> MPBall
piBallP (WithCurrentPrec (CN MPBall) p -> Precision
forall k (p :: k) (proxy :: k -> *).
HasCurrentPrecision p =>
proxy p -> Precision
getCurrentPrecision WithCurrentPrec (CN MPBall) p
r)
sqrt :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
sqrt = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
sqrt
exp :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
exp = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
exp
log :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
log = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
log
sin :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
sin = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
sin
cos :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
cos = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
cos
asin :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
asin = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
asin
acos :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
acos = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
acos
atan :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
atan = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
atan
sinh :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
sinh = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
sinh
cosh :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
cosh = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
cosh
asinh :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
asinh = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
asinh
acosh :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
acosh = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
acosh
atanh :: WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
atanh = (CN MPBall -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> WithCurrentPrec (CN MPBall) p
forall k t1 t2 (p :: k).
(t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 CN MPBall -> CN MPBall
forall a. Floating a => a -> a
atanh
instance
(HasLimits ix (CN MPBall -> CN MPBall)
, LimitType ix (CN MPBall -> CN MPBall) ~ (CN MPBall -> CN MPBall)
,HasCurrentPrecision p)
=>
HasLimits ix (WithCurrentPrec (CN MPBall) p)
where
type LimitType ix (WithCurrentPrec (CN MPBall) p) = WithCurrentPrec (CN MPBall) p
limit :: (ix -> WithCurrentPrec (CN MPBall) p)
-> LimitType ix (WithCurrentPrec (CN MPBall) p)
limit (ix -> WithCurrentPrec (CN MPBall) p
s :: ix -> (WithCurrentPrec (CN MPBall) p)) =
CN MPBall -> WithCurrentPrec (CN MPBall) p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (CN MPBall -> WithCurrentPrec (CN MPBall) p)
-> CN MPBall -> WithCurrentPrec (CN MPBall) p
forall a b. (a -> b) -> a -> b
$ (ix -> CN MPBall -> CN MPBall)
-> LimitType ix (CN MPBall -> CN MPBall)
forall ix s. HasLimits ix s => (ix -> s) -> LimitType ix s
limit (ix -> CN MPBall -> CN MPBall
snop) (CN MPBall -> CN MPBall) -> CN MPBall -> CN MPBall
forall a b. (a -> b) -> a -> b
$ CN MPBall
sample
where
sample :: CN MPBall
sample :: CN MPBall
sample = Precision -> CN MPBall -> CN MPBall
forall t. CanSetPrecision t => Precision -> t -> t
setPrecision (WithCurrentPrec MPBall p -> Precision
forall k (p :: k) (proxy :: k -> *).
HasCurrentPrecision p =>
proxy p -> Precision
getCurrentPrecision WithCurrentPrec MPBall p
sampleP) CN MPBall
0
sampleP :: WithCurrentPrec MPBall p
sampleP :: WithCurrentPrec MPBall p
sampleP = String -> WithCurrentPrec MPBall p
forall a. HasCallStack => String -> a
error String
"sampleP is not defined, it is only a type proxy"
snop :: ix -> (CN MPBall -> CN MPBall)
snop :: ix -> CN MPBall -> CN MPBall
snop ix
ix CN MPBall
_sample = WithCurrentPrec (CN MPBall) p -> CN MPBall
forall t k (p :: k). WithCurrentPrec t p -> t
unWithCurrentPrec (WithCurrentPrec (CN MPBall) p -> CN MPBall)
-> WithCurrentPrec (CN MPBall) p -> CN MPBall
forall a b. (a -> b) -> a -> b
$ ix -> WithCurrentPrec (CN MPBall) p
s ix
ix
lift1 :: (t1 -> t2) -> (WithCurrentPrec t1 p) -> (WithCurrentPrec t2 p)
lift1 :: (t1 -> t2) -> WithCurrentPrec t1 p -> WithCurrentPrec t2 p
lift1 t1 -> t2
f (WithCurrentPrec t1
v1) = t2 -> WithCurrentPrec t2 p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (t1 -> t2
f t1
v1)
lift2 :: (t1 -> t2 -> t3) -> (WithCurrentPrec t1 p) -> (WithCurrentPrec t2 p) -> (WithCurrentPrec t3 p)
lift2 :: (t1 -> t2 -> t3)
-> WithCurrentPrec t1 p
-> WithCurrentPrec t2 p
-> WithCurrentPrec t3 p
lift2 t1 -> t2 -> t3
f (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t3 -> WithCurrentPrec t3 p
forall k t (p :: k). t -> WithCurrentPrec t p
WithCurrentPrec (t1 -> t2 -> t3
f t1
v1 t2
v2)
lift2P :: (t1 -> t2 -> t3) -> (WithCurrentPrec t1 p) -> (WithCurrentPrec t2 p) -> t3
lift2P :: (t1 -> t2 -> t3)
-> WithCurrentPrec t1 p -> WithCurrentPrec t2 p -> t3
lift2P t1 -> t2 -> t3
f (WithCurrentPrec t1
v1) (WithCurrentPrec t2
v2) = t1 -> t2 -> t3
f t1
v1 t2
v2
_example1 :: CN MPBall
_example1 :: CN MPBall
_example1 = Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall
forall t.
Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec t n) -> t
runWithPrec (Integer -> Precision
prec Integer
1000) forall a. Floating a => a
forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n
pi
_example2 :: CN MPBall
_example2 :: CN MPBall
_example2 = Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall
forall t.
Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec t n) -> t
runWithPrec (Integer -> Precision
prec Integer
1000) ((forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall)
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall
forall a b. (a -> b) -> a -> b
$ WithCurrentPrec (CN MPBall) n
forall a. Floating a => a
pi WithCurrentPrec (CN MPBall) n
-> WithCurrentPrec (CN MPBall) n -> WithCurrentPrec (CN MPBall) n
forall a. Num a => a -> a -> a
- WithCurrentPrec (CN MPBall) n
forall a. Floating a => a
pi
_example3 :: CN MPBall
_example3 :: CN MPBall
_example3 = Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall
forall t.
Precision
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec t n) -> t
runWithPrec (Integer -> Precision
prec Integer
1000) ((forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall)
-> (forall (n :: Nat). KnownNat n => WithCurrentPrec (CN MPBall) n)
-> CN MPBall
forall a b. (a -> b) -> a -> b
$ WithCurrentPrec (CN MPBall) n -> WithCurrentPrec (CN MPBall) n
forall a. Floating a => a -> a
sqrt WithCurrentPrec (CN MPBall) n
2