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

    module Typst.Module.Calc
      ( calcModule,
      )
    where

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