aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Builtins.hs17
-rw-r--r--src/Evaluator.hs1
-rw-r--r--todo.md1
3 files changed, 17 insertions, 2 deletions
diff --git a/src/Builtins.hs b/src/Builtins.hs
index 0ddf89f..2dac829 100644
--- a/src/Builtins.hs
+++ b/src/Builtins.hs
@@ -13,6 +13,9 @@ builtinEnv = M.fromList [
builtinSubtract2,
builtinMultiply2,
builtinDivide2,
+ -- comparisons
+ builtinEq2,
+ builtinLt2,
-- conversions
builtinFmt,
builtinFloor,
@@ -106,6 +109,20 @@ builtinDivide2 = (name, ASTFunction fn1) where
fn2 _ ast2 = throwL $ argError2 name ast1 ast2
fn1 _ ast1 = throwL $ argError1 name ast1
+builtinEq2 :: (String, AST)
+builtinEq2 = (name, ASTFunction fn1) where
+ name = "eq?"
+ fn1 _ ast1 =
+ return $ ASTFunction $ fn2 where
+ fn2 _ ast2 = return $ ASTBoolean $ ast1 == ast2
+
+builtinLt2 :: (String, AST)
+builtinLt2 = (name, ASTFunction fn1) where
+ name = "lt?"
+ fn1 _ ast1 =
+ return $ ASTFunction $ fn2 where
+ fn2 _ ast2 = return $ ASTBoolean $ ast1 <= ast2
+
builtinFloor :: (String, AST)
builtinFloor = (name, ASTFunction fn1) where
name = "floor"
diff --git a/src/Evaluator.hs b/src/Evaluator.hs
index a0c6151..009f108 100644
--- a/src/Evaluator.hs
+++ b/src/Evaluator.hs
@@ -117,7 +117,6 @@ evaluateMatch env args = do
++ "- matching on expr: " ++ show actualExpr ++ "\n"
++ "- arguments: " ++ show rest)
-
(_, evaledActual) <- evaluate env actualExpr
ret <- matchPairs (actualExpr, evaledActual) pairs
return (env, ret)
diff --git a/todo.md b/todo.md
index 4e71090..9f61e8f 100644
--- a/todo.md
+++ b/todo.md
@@ -3,7 +3,6 @@
In order of priority
- Write tests!
-- Add builtins to compare numbers (eq?, lt?)
- Add import function with support for qualified imports
- Come up with a name for the language
- Add auto import for standard library (std) and a flag to disable auto import