{-# LANGUAGE BlockArguments      #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE GADTs               #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}

-- | A tiny standard library.
module Dovetail.Prelude where
  
import Control.Monad.Fix (MonadFix)
import Data.Char (chr, ord)
import Data.Text qualified as Text
import Data.Vector qualified as Vector
import Dovetail.Evaluate (ToValue, ToValueRHS)
import Dovetail.FFI (FFI(..))
import Dovetail.FFI.Builder (array, boolean, char, int, string, number, (~>))
import Dovetail.FFI.Builder qualified as FFI
import Dovetail.Types
import Language.PureScript qualified as P

stdlib :: MonadFix m => [FFI m]
stdlib :: [FFI m]
stdlib = 
  [ FFI m
forall (m :: * -> *). MonadFix m => FFI m
prelude
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeArray
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeString
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeChar
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeNumber
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeInt
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeBoolean
  , FFI m
forall (m :: * -> *). MonadFix m => FFI m
preludeDebug
  ]

prelude :: MonadFix m => FFI m
prelude :: FFI m
prelude = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude") do
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m)))
-> (Value m -> EvalT m (Value m))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"identity") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a -> FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
a)
    Value m -> EvalT m (Value m)
forall (f :: * -> *) a. Applicative f => a -> f a
pure
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         ((Value m -> Value m -> EvalT m (Value m))
          -> Value m -> Value m -> EvalT m (Value m))
         ((Value m -> Value m -> EvalT m (Value m))
          -> Value m -> Value m -> EvalT m (Value m)))
-> ((Value m -> Value m -> EvalT m (Value m))
    -> Value m -> Value m -> EvalT m (Value m))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"flip") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
c -> (FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Value m -> EvalT m (Value m))
     (Value m -> Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
c) FunctionType
  m
  (Value m -> Value m -> EvalT m (Value m))
  (Value m -> Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Value m -> EvalT m (Value m))
     (Value m -> Value m -> EvalT m (Value m))
-> FunctionType
     m
     ((Value m -> Value m -> EvalT m (Value m))
      -> Value m -> Value m -> EvalT m (Value m))
     ((Value m -> Value m -> EvalT m (Value m))
      -> Value m -> Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Value m -> EvalT m (Value m))
     (Value m -> Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
c)
    (Value m -> Value m -> EvalT m (Value m))
-> Value m -> Value m -> EvalT m (Value m)
forall a b c. (a -> b -> c) -> b -> a -> c
flip
    
preludeArray :: MonadFix m => FFI m
preludeArray :: FFI m
preludeArray = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Array") do
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         ((Value m -> EvalT m (Value m))
          -> Vector (Value m) -> EvalT m (Vector (Value m)))
         ((Value m -> EvalT m (Value m))
          -> Vector (Value m) -> EvalT m (Vector (Value m))))
-> ((Value m -> EvalT m (Value m))
    -> Vector (Value m) -> EvalT m (Vector (Value m)))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"map") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
b -> (FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b) FunctionType
  m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
-> FunctionType
     m
     ((Value m -> EvalT m (Value m))
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
     ((Value m -> EvalT m (Value m))
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
b)
    (Value m -> EvalT m (Value m))
-> Vector (Value m) -> EvalT m (Vector (Value m))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         ((Value m -> EvalT m Bool)
          -> Vector (Value m) -> EvalT m (Vector (Value m)))
         ((Value m -> EvalT m Bool)
          -> Vector (Value m) -> EvalT m (Vector (Value m))))
-> ((Value m -> EvalT m Bool)
    -> Vector (Value m) -> EvalT m (Vector (Value m)))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"filter") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a -> (FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType
     m (Value m -> EvalT m Bool) (Value m -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean) FunctionType m (Value m -> EvalT m Bool) (Value m -> EvalT m Bool)
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
-> FunctionType
     m
     ((Value m -> EvalT m Bool)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
     ((Value m -> EvalT m Bool)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a)
    (Value m -> EvalT m Bool)
-> Vector (Value m) -> EvalT m (Vector (Value m))
forall (m :: * -> *) a.
Monad m =>
(a -> m Bool) -> Vector a -> m (Vector a)
Vector.filterM
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         ((Value m -> Value m -> EvalT m (Value m))
          -> Value m -> Vector (Value m) -> EvalT m (Value m))
         ((Value m -> Value m -> EvalT m (Value m))
          -> Value m -> Vector (Value m) -> EvalT m (Value m)))
-> ((Value m -> Value m -> EvalT m (Value m))
    -> Value m -> Vector (Value m) -> EvalT m (Value m))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"foldl") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
b -> (FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Value m -> EvalT m (Value m))
     (Value m -> Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b) FunctionType
  m
  (Value m -> Value m -> EvalT m (Value m))
  (Value m -> Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Vector (Value m) -> EvalT m (Value m))
     (Value m -> Vector (Value m) -> EvalT m (Value m))
-> FunctionType
     m
     ((Value m -> Value m -> EvalT m (Value m))
      -> Value m -> Vector (Value m) -> EvalT m (Value m))
     ((Value m -> Value m -> EvalT m (Value m))
      -> Value m -> Vector (Value m) -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Value m))
     (Vector (Value m) -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Vector (Value m) -> EvalT m (Value m))
     (Value m -> Vector (Value m) -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Value m))
     (Vector (Value m) -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b)
    (Value m -> Value m -> EvalT m (Value m))
-> Value m -> Vector (Value m) -> EvalT m (Value m)
forall (m :: * -> *) a b.
Monad m =>
(a -> b -> m a) -> a -> Vector b -> m a
Vector.foldM
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         ((Value m -> Value m -> EvalT m (Value m))
          -> Vector (Value m)
          -> Vector (Value m)
          -> EvalT m (Vector (Value m)))
         ((Value m -> Value m -> EvalT m (Value m))
          -> Vector (Value m)
          -> Vector (Value m)
          -> EvalT m (Vector (Value m))))
-> ((Value m -> Value m -> EvalT m (Value m))
    -> Vector (Value m)
    -> Vector (Value m)
    -> EvalT m (Vector (Value m)))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"zipWith") 
    (\FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
c -> (FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Value m -> Value m -> EvalT m (Value m))
     (Value m -> Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Value m -> EvalT m (Value m)) (Value m -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
c) FunctionType
  m
  (Value m -> Value m -> EvalT m (Value m))
  (Value m -> Value m -> EvalT m (Value m))
-> FunctionType
     m
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
-> FunctionType
     m
     ((Value m -> Value m -> EvalT m (Value m))
      -> Vector (Value m)
      -> Vector (Value m)
      -> EvalT m (Vector (Value m)))
     ((Value m -> Value m -> EvalT m (Value m))
      -> Vector (Value m)
      -> Vector (Value m)
      -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
b FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
c)
    (Value m -> Value m -> EvalT m (Value m))
-> Vector (Value m)
-> Vector (Value m)
-> EvalT m (Vector (Value m))
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
Vector.zipWithM
  Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m
         (Vector (Value m)
          -> Vector (Value m) -> EvalT m (Vector (Value m)))
         (Vector (Value m)
          -> Vector (Value m) -> EvalT m (Vector (Value m))))
-> (Vector (Value m)
    -> Vector (Value m) -> EvalT m (Vector (Value m)))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"append")
    (\FunctionType m (Value m) (EvalT m (Value m))
a -> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m)
      -> Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
-> FunctionType
     m
     (Vector (Value m) -> EvalT m (Vector (Value m)))
     (Vector (Value m) -> EvalT m (Vector (Value m)))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m (Vector (Value m)) (EvalT m (Vector (Value m)))
forall (m :: * -> *) l r.
FunctionType m l r
-> FunctionType m (Vector l) (EvalT m (Vector l))
array FunctionType m (Value m) (EvalT m (Value m))
a)
    (\Vector (Value m)
xs Vector (Value m)
ys -> Vector (Value m) -> EvalT m (Vector (Value m))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Vector (Value m)
xs Vector (Value m) -> Vector (Value m) -> Vector (Value m)
forall a. Semigroup a => a -> a -> a
<> Vector (Value m)
ys))
  
preludeString :: MonadFix m => FFI m
preludeString :: FFI m
preludeString = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.String") do
  FunctionType m Text (EvalT m Text) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Eq a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
eqOps FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string
  FunctionType m Text (EvalT m Text) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Ord a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string
  
  Ident
-> FunctionType
     m (Text -> Text -> EvalT m Text) (Text -> Text -> EvalT m Text)
-> (Text -> Text -> EvalT m Text)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"append")
    (FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string FunctionType m Text (EvalT m Text)
-> FunctionType m (Text -> EvalT m Text) (Text -> EvalT m Text)
-> FunctionType
     m (Text -> Text -> EvalT m Text) (Text -> Text -> EvalT m Text)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string FunctionType m Text (EvalT m Text)
-> FunctionType m Text (EvalT m Text)
-> FunctionType m (Text -> EvalT m Text) (Text -> EvalT m Text)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string)
    (\Text
xs Text
ys -> Text -> EvalT m Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text
xs Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ys))
  Ident
-> FunctionType m (Char -> EvalT m Text) (Char -> EvalT m Text)
-> (Char -> EvalT m Text)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"singleton")
    (FunctionType m Char (EvalT m Char)
forall (m :: * -> *). FunctionType m Char (EvalT m Char)
char FunctionType m Char (EvalT m Char)
-> FunctionType m Text (EvalT m Text)
-> FunctionType m (Char -> EvalT m Text) (Char -> EvalT m Text)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string)
    (Text -> EvalT m Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> EvalT m Text) -> (Char -> Text) -> Char -> EvalT m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
Text.singleton)
    
preludeChar :: MonadFix m => FFI m
preludeChar :: FFI m
preludeChar = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Char") do
  FunctionType m Char (EvalT m Char) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Eq a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
eqOps FunctionType m Char (EvalT m Char)
forall (m :: * -> *). FunctionType m Char (EvalT m Char)
char
  FunctionType m Text (EvalT m Text) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Ord a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string
  
  Ident
-> FunctionType
     m (Integer -> EvalT m Char) (Integer -> EvalT m Char)
-> (Integer -> EvalT m Char)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"chr")
    (FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int FunctionType m Integer (EvalT m Integer)
-> FunctionType m Char (EvalT m Char)
-> FunctionType
     m (Integer -> EvalT m Char) (Integer -> EvalT m Char)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Char (EvalT m Char)
forall (m :: * -> *). FunctionType m Char (EvalT m Char)
char)
    (Char -> EvalT m Char
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char -> EvalT m Char)
-> (Integer -> Char) -> Integer -> EvalT m Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Char
chr (Int -> Char) -> (Integer -> Int) -> Integer -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
  Ident
-> FunctionType
     m (Char -> EvalT m Integer) (Char -> EvalT m Integer)
-> (Char -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"ord")
    (FunctionType m Char (EvalT m Char)
forall (m :: * -> *). FunctionType m Char (EvalT m Char)
char FunctionType m Char (EvalT m Char)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Char -> EvalT m Integer) (Char -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> EvalT m Integer)
-> (Char -> Integer) -> Char -> EvalT m Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer) -> (Char -> Int) -> Char -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord)
    
preludeNumber :: MonadFix m => FFI m
preludeNumber :: FFI m
preludeNumber = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Number") do
  FunctionType m Double (EvalT m Double) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Num a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
numOps FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number
  FunctionType m Double (EvalT m Double) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Ord a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number

  Ident
-> FunctionType
     m
     (Double -> Double -> EvalT m Double)
     (Double -> Double -> EvalT m Double)
-> (Double -> Double -> EvalT m Double)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"div")
    (FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType
     m (Double -> EvalT m Double) (Double -> EvalT m Double)
-> FunctionType
     m
     (Double -> Double -> EvalT m Double)
     (Double -> Double -> EvalT m Double)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType m Double (EvalT m Double)
-> FunctionType
     m (Double -> EvalT m Double) (Double -> EvalT m Double)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number)
    (\Double
x Double
y -> Double -> EvalT m Double
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Double
x Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
y))

  Ident
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
-> (Double -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"floor")
    (FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> EvalT m Integer)
-> (Double -> Integer) -> Double -> EvalT m Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
floor)
  Ident
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
-> (Double -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"ceiling")
    (FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> EvalT m Integer)
-> (Double -> Integer) -> Double -> EvalT m Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
ceiling)
  Ident
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
-> (Double -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"round")
    (FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> EvalT m Integer)
-> (Double -> Integer) -> Double -> EvalT m Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
round)
  Ident
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
-> (Double -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"truncate")
    (FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number FunctionType m Double (EvalT m Double)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Double -> EvalT m Integer) (Double -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> EvalT m Integer)
-> (Double -> Integer) -> Double -> EvalT m Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Integer
forall a b. (RealFrac a, Integral b) => a -> b
truncate)
  
preludeInt :: MonadFix m => FFI m
preludeInt :: FFI m
preludeInt = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Int") do
  FunctionType m Integer (EvalT m Integer) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Eq a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
eqOps FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int
  FunctionType m Integer (EvalT m Integer) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Num a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
numOps FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int
  FunctionType m Integer (EvalT m Integer) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Ord a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int

  Ident
-> FunctionType
     m
     (Integer -> Integer -> EvalT m Integer)
     (Integer -> Integer -> EvalT m Integer)
-> (Integer -> Integer -> EvalT m Integer)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"div")
    (FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Integer -> EvalT m Integer) (Integer -> EvalT m Integer)
-> FunctionType
     m
     (Integer -> Integer -> EvalT m Integer)
     (Integer -> Integer -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int FunctionType m Integer (EvalT m Integer)
-> FunctionType m Integer (EvalT m Integer)
-> FunctionType
     m (Integer -> EvalT m Integer) (Integer -> EvalT m Integer)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int)
    (\Integer
x Integer
y -> Integer -> EvalT m Integer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer
x Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`div` Integer
y))

  Ident
-> FunctionType
     m (Integer -> EvalT m Double) (Integer -> EvalT m Double)
-> (Integer -> EvalT m Double)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"toNumber")
    (FunctionType m Integer (EvalT m Integer)
forall (m :: * -> *). FunctionType m Integer (EvalT m Integer)
int FunctionType m Integer (EvalT m Integer)
-> FunctionType m Double (EvalT m Double)
-> FunctionType
     m (Integer -> EvalT m Double) (Integer -> EvalT m Double)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Double (EvalT m Double)
forall (m :: * -> *). FunctionType m Double (EvalT m Double)
number)
    (Double -> EvalT m Double
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Double -> EvalT m Double)
-> (Integer -> Double) -> Integer -> EvalT m Double
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
  
preludeBoolean :: MonadFix m => FFI m
preludeBoolean :: FFI m
preludeBoolean = ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Boolean") do
  FunctionType m Bool (EvalT m Bool) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Eq a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
eqOps FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean
  FunctionType m Text (EvalT m Text) -> FFIBuilder m ()
forall (m :: * -> *) a.
(ToValue m a, ToValueRHS m (EvalT m a), Ord a) =>
FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string
  
  Ident
-> FunctionType
     m (Bool -> Bool -> EvalT m Bool) (Bool -> Bool -> EvalT m Bool)
-> (Bool -> Bool -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"and")
    (FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean FunctionType m Bool (EvalT m Bool)
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
-> FunctionType
     m (Bool -> Bool -> EvalT m Bool) (Bool -> Bool -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean FunctionType m Bool (EvalT m Bool)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\Bool
x Bool
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
x Bool -> Bool -> Bool
&& Bool
y))
  Ident
-> FunctionType
     m (Bool -> Bool -> EvalT m Bool) (Bool -> Bool -> EvalT m Bool)
-> (Bool -> Bool -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"or")
    (FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean FunctionType m Bool (EvalT m Bool)
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
-> FunctionType
     m (Bool -> Bool -> EvalT m Bool) (Bool -> Bool -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean FunctionType m Bool (EvalT m Bool)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\Bool
x Bool
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
x Bool -> Bool -> Bool
|| Bool
y))
  Ident
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
-> (Bool -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"not")
    (FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean FunctionType m Bool (EvalT m Bool)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (Bool -> EvalT m Bool) (Bool -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> EvalT m Bool) -> (Bool -> Bool) -> Bool -> EvalT m Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Bool
not)
    
preludeDebug :: MonadFix m => FFI m
preludeDebug :: FFI m
preludeDebug = 
  ModuleName -> FFIBuilder m () -> FFI m
forall (m :: * -> *) a. ModuleName -> FFIBuilder m a -> FFI m
FFI.evalFFIBuilder (Text -> ModuleName
P.ModuleName Text
"Prelude.Debug") do
    Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m (Value m -> EvalT m Text) (Value m -> EvalT m Text))
-> (Value m -> EvalT m Text)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"show")
      (\FunctionType m (Value m) (EvalT m (Value m))
a -> FunctionType m (Value m) (EvalT m (Value m))
a FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType m Text (EvalT m Text)
-> FunctionType
     m (Value m -> EvalT m Text) (Value m -> EvalT m Text)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string)
      (Text -> EvalT m Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> EvalT m Text)
-> (Value m -> Text) -> Value m -> EvalT m Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RenderValueOptions -> Value m -> Text
forall (m :: * -> *). RenderValueOptions -> Value m -> Text
renderValue (Bool -> Maybe Int -> RenderValueOptions
RenderValueOptions Bool
False Maybe Int
forall a. Maybe a
Nothing))
    Ident
-> (FunctionType m (Value m) (EvalT m (Value m))
    -> FunctionType
         m (Text -> EvalT m (Value m)) (Text -> EvalT m (Value m)))
-> (Text -> EvalT m (Value m))
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"crash")
      (\FunctionType m (Value m) (EvalT m (Value m))
a -> FunctionType m Text (EvalT m Text)
forall (m :: * -> *). FunctionType m Text (EvalT m Text)
string FunctionType m Text (EvalT m Text)
-> FunctionType m (Value m) (EvalT m (Value m))
-> FunctionType
     m (Text -> EvalT m (Value m)) (Text -> EvalT m (Value m))
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m (Value m) (EvalT m (Value m))
a)
      (EvaluationErrorType m -> EvalT m (Value m)
forall (x :: * -> *) (m :: * -> *) a.
(MonadError (EvaluationError x) m,
 MonadReader (EvaluationContext x) m) =>
EvaluationErrorType x -> m a
throwErrorWithContext (EvaluationErrorType m -> EvalT m (Value m))
-> (Text -> EvaluationErrorType m) -> Text -> EvalT m (Value m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> EvaluationErrorType m
forall (m :: * -> *). Text -> EvaluationErrorType m
OtherError)

eqOps 
  :: (ToValue m a, ToValueRHS m (EvalT m a), Eq a)
  => FFI.FunctionType m a (EvalT m a)
  -> FFI.FFIBuilder m ()
eqOps :: FunctionType m a (EvalT m a) -> FFIBuilder m ()
eqOps FunctionType m a (EvalT m a)
ty = do
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"eq")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"neq")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
/= a
y))

numOps 
  :: (ToValue m a, ToValueRHS m (EvalT m a), Num a)
  => FFI.FunctionType m a (EvalT m a)
  -> FFI.FFIBuilder m ()
numOps :: FunctionType m a (EvalT m a) -> FFIBuilder m ()
numOps FunctionType m a (EvalT m a)
ty = do
  Ident
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
-> (a -> a -> EvalT m a)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"add")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty)
    (\a
x a
y -> a -> EvalT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> a
forall a. Num a => a -> a -> a
+ a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
-> (a -> a -> EvalT m a)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"sub")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty)
    (\a
x a
y -> a -> EvalT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> a
forall a. Num a => a -> a -> a
- a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
-> (a -> a -> EvalT m a)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"mul")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty)
    (\a
x a
y -> a -> EvalT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> a
forall a. Num a => a -> a -> a
* a
y))
    
ordOps 
  :: (ToValue m a, ToValueRHS m (EvalT m a), Ord a)
  => FFI.FunctionType m a (EvalT m a)
  -> FFI.FFIBuilder m ()
ordOps :: FunctionType m a (EvalT m a) -> FFIBuilder m ()
ordOps FunctionType m a (EvalT m a)
ty = do
  Ident
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
-> (a -> a -> EvalT m a)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"min")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty)
    (\a
x a
y -> a -> EvalT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> a
forall a. Ord a => a -> a -> a
`min` a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
-> (a -> a -> EvalT m a)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"max")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
-> FunctionType m (a -> a -> EvalT m a) (a -> a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m a) (a -> EvalT m a)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty)
    (\a
x a
y -> a -> EvalT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> a
forall a. Ord a => a -> a -> a
`max` a
y))
    
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"lt")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"gt")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"lte")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
y))
  Ident
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
-> (a -> a -> EvalT m Bool)
-> FFIBuilder m ()
forall (m :: * -> *) a ty.
(MonadFix m, ToValue m a, ForAll m a ty) =>
Ident -> ty -> a -> FFIBuilder m ()
FFI.foreignImport (Text -> Ident
P.Ident Text
"gte")
    (FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
-> FunctionType m (a -> a -> EvalT m Bool) (a -> a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m a (EvalT m a)
ty FunctionType m a (EvalT m a)
-> FunctionType m Bool (EvalT m Bool)
-> FunctionType m (a -> EvalT m Bool) (a -> EvalT m Bool)
forall (m :: * -> *) al ar bl br.
FunctionType m al ar
-> FunctionType m bl br -> FunctionType m (al -> br) (al -> br)
~> FunctionType m Bool (EvalT m Bool)
forall (m :: * -> *). FunctionType m Bool (EvalT m Bool)
boolean)
    (\a
x a
y -> Bool -> EvalT m Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
y))