{---- - Basic.hs - a set of primitive operations, and the root environment - of all noodle namespaces ---- - Author: Jesse Rudolph - See LICENSE for licensing details ----------------------------------------------------------------- -} module Language.Noodle.Lib.Basic (env,decls) where import qualified Language.Noodle.Lib.String as StringLib import qualified Language.Noodle.Lib.Boolean as BoolLib import qualified Language.Noodle.Lib.Math as MathLib import qualified Language.Noodle.Lib.IO as IOLib import qualified Language.Noodle.Lib.Prod as ProdLib import qualified Language.Noodle.Lib.Function as FunctLib import Language.Noodle.Evaluation import Data.List env :: Env env = extenv decls decls :: [(String,Val)] -- export declarations of basic libs decls = MathLib.decls ++ IOLib.decls ++ BoolLib.decls ++ StringLib.decls ++ ProdLib.decls ++ FunctLib.decls ++ -- also export each one individually as a module [ ("math", extmod MathLib.env) , ("io" , extmod IOLib.env) , ("bool", extmod BoolLib.env) , ("string", extmod StringLib.env) , ("product", extmod ProdLib.env) , ("function", extmod FunctLib.env) -- these dont seem to fit in any of the other libraries , (":", extop (\e1 e2 -> return e2)) , ("==", extop equal) , ("error", extfun (\v -> return $ rtError v)) , ("nil", Thunk $ return Nil) ] equal :: Val -> Val -> IO Val equal v v2 = if v == v2 then return $ Symbol "True" else return $ Nil