{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Typst.Module.Calc
  ( calcModule,
  )
where

import Control.Applicative ((<|>))
import qualified Data.Map as M
import Data.Maybe (fromMaybe)
import Typst.Types
import Typst.Util

calcModule :: M.Map Identifier Val
calcModule :: Map Identifier Val
calcModule =
  forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
    [ ( Identifier
"abs",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Val
v :: Val) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Double
n :: Double) <- forall a (m :: * -> *).
(FromVal a, MonadPlus m, MonadFail m) =>
Val -> m a
fromVal Val
v
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
            if Double
n forall a. Ord a => a -> a -> Bool
< Double
0
              then forall a. a -> Maybe a -> a
fromMaybe Val
v forall a b. (a -> b) -> a -> b
$ forall a. Negatable a => a -> Maybe a
maybeNegate Val
v
              else Val
v
      ),
      ( Identifier
"binom",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Integer
n :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Integer
k :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [(Integer
1 forall a. Num a => a -> a -> a
+ Integer
n forall a. Num a => a -> a -> a
- Integer
k) .. Integer
n] forall a. Integral a => a -> a -> a
`div` forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [Integer
1 .. Integer
k]
      ),
      ( Identifier
"ceil",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Double
x :: Double) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger (forall a b. (RealFrac a, Integral b) => a -> b
ceiling Double
x)
      ),
      ( Identifier
"clamp",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Val
value <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          Val
minval <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          Val
maxval <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
3
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
            if Val
value forall a. Ord a => a -> a -> Bool
< Val
minval
              then Val
minval
              else
                if Val
value forall a. Ord a => a -> a -> Bool
> Val
maxval
                  then Val
maxval
                  else Val
value
      ),
      ( Identifier
"even",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Val
v <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          case Val
v of
            VInteger Integer
i -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Bool -> Val
VBoolean forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> Bool
even Integer
i
            Val
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"even requires an integer argument"
      ),
      ( Identifier
"fact",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Val
v <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          case Val
v of
            VInteger Integer
i
              | Integer
i forall a. Eq a => a -> a -> Bool
== Integer
0 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger Integer
1
              | Integer
i forall a. Ord a => a -> a -> Bool
> Integer
0 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [Integer
1 .. Integer
i]
            Val
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"odd requires a non-negative integer argument"
      ),
      ( Identifier
"floor",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Double
x :: Double) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger (forall a b. (RealFrac a, Integral b) => a -> b
floor Double
x)
      ),
      ( Identifier
"fract",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Val
v :: Val) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          case Val
v of
            VInteger Integer
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger Integer
0
            VFloat Double
x -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat (Double
x forall a. Num a => a -> a -> a
- forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a b. (RealFrac a, Integral b) => a -> b
truncate Double
x :: Integer))
            Val
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"fract requires integer or float argument"
      ),
      ( Identifier
"gcd",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Integer
x <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          Integer
y <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> a -> a
gcd Integer
x Integer
y
      ),
      ( Identifier
"lcm",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Integer
x <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          Integer
y <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> a -> a
lcm Integer
x Integer
y
      ),
      ( Identifier
"log",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Double
b <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Identifier -> ReaderT Arguments (MP m) a
namedArg Identifier
"base" forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure Double
10
          Double
n <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          if Double
n forall a. Ord a => a -> a -> Bool
<= Double
0
            then forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"value must be strictly positive"
            else
              if Double
b forall a. Eq a => a -> a -> Bool
== Double
0
                then forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"base may not be 0"
                else forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall a b. (a -> b) -> a -> b
$ forall a. Floating a => a -> a -> a
logBase Double
b Double
n
      ),
      ( Identifier
"max",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          [Val]
vs <- forall (m :: * -> *). Monad m => ReaderT Arguments (MP m) [Val]
allArgs
          case [Val]
vs of
            [] -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"max requires one or more argument"
            Val
_ : [Val]
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum [Val]
vs
      ),
      ( Identifier
"min",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          [Val]
vs <- forall (m :: * -> *). Monad m => ReaderT Arguments (MP m) [Val]
allArgs
          case [Val]
vs of
            [] -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"min requires one or more argument"
            Val
_ : [Val]
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum [Val]
vs
      ),
      ( Identifier
"mod",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Integer
a :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Integer
b :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ Integer
a forall a. Integral a => a -> a -> a
`mod` Integer
b
      ),
      ( Identifier
"odd",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Val
v <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          case Val
v of
            VInteger Integer
i -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Bool -> Val
VBoolean forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> Bool
odd Integer
i
            Val
_ -> forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"odd requires an integer argument"
      ),
      ( Identifier
"perm",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Integer
b <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          Integer
n <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
            if Integer
n forall a. Ord a => a -> a -> Bool
> Integer
b
              then Integer -> Val
VInteger Integer
0
              else Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> a -> a
div (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [Integer
1 .. Integer
b]) (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [Integer
1 .. (Integer
b forall a. Num a => a -> a -> a
- Integer
n)])
      ),
      ( Identifier
"pow",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Val
base <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          Val
ex <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          case (Val
base, Val
ex) of
            (VInteger Integer
x, VInteger Integer
y) -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ Integer
x forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
y
            (Val, Val)
_ -> do
              (Double
base' :: Double) <- forall a (m :: * -> *).
(FromVal a, MonadPlus m, MonadFail m) =>
Val -> m a
fromVal Val
base
              (Integer
ex' :: Integer) <- forall a (m :: * -> *).
(FromVal a, MonadPlus m, MonadFail m) =>
Val -> m a
fromVal Val
ex
              forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall a b. (a -> b) -> a -> b
$ (Double
base') forall a b. (Num a, Integral b) => a -> b -> a
^ (Integer
ex')
      ),
      ( Identifier
"quo",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Integer
a :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Integer
b :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ Integer
a forall a. Integral a => a -> a -> a
`quot` Integer
b
      ),
      ( Identifier
"rem",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Integer
a :: Integer, Double
f :: Double) <- forall a b. (RealFrac a, Integral b) => a -> (b, a)
properFraction forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Integer
b :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
            if Double
f forall a. Eq a => a -> a -> Bool
== Double
0
              then Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall a. Integral a => a -> a -> a
rem Integer
a Integer
b
              else Double -> Val
VFloat forall a b. (a -> b) -> a -> b
$ forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Integral a => a -> a -> a
rem Integer
a Integer
b) forall a. Num a => a -> a -> a
+ Double
f
      ),
      ( Identifier
"round",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Double
x :: Double) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          (Integer
digits :: Integer) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Identifier -> ReaderT Arguments (MP m) a
namedArg Identifier
"digits" forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure Integer
0
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
            if Integer
digits forall a. Ord a => a -> a -> Bool
> Integer
0
              then
                Double -> Val
VFloat forall a b. (a -> b) -> a -> b
$
                  forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a b. (RealFrac a, Integral b) => a -> b
round (Double
x forall a. Num a => a -> a -> a
* Double
10 forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
digits) :: Integer)
                    forall a. Fractional a => a -> a -> a
/ Double
10 forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
digits
              else Integer -> Val
VInteger (forall a b. (RealFrac a, Integral b) => a -> b
round Double
x)
      ),
      ( Identifier
"trunc",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          (Double
x :: Double) <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Integer -> Val
VInteger forall a b. (a -> b) -> a -> b
$ forall a b. (RealFrac a, Integral b) => a -> b
truncate Double
x
      ),
      ( Identifier
"sqrt",
        (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ do
          Double
n <- forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1
          if Double
n forall a. Ord a => a -> a -> Bool
< Double
0
            then forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"can't take square root of negative number"
            else forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall a b. (a -> b) -> a -> b
$ forall a. Floating a => a -> a
sqrt Double
n
      ),
      (Identifier
"cos", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
cos forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"cosh", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
cosh forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"sin", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
sin forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"sinh", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
sinh forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"tan", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
tan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"tanh", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VFloat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
tanh forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"acos", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VAngle forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
acos forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"asin", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VAngle forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
asin forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"atan", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VAngle forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Floating a => a -> a
atan forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1),
      (Identifier
"atan2", (forall (m' :: * -> *). Monad m' => ReaderT Arguments (MP m') Val)
-> Val
makeFunction forall a b. (a -> b) -> a -> b
$ Double -> Val
VAngle forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. RealFloat a => a -> a -> a
atan2 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) a.
(Monad m, FromVal a) =>
Int -> ReaderT Arguments (MP m) a
nthArg Int
2)),
      (Identifier
"e", Double -> Val
VFloat (forall a. Floating a => a -> a
exp Double
1)),
      (Identifier
"pi", Double -> Val
VFloat forall a. Floating a => a
pi)
    ]