aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Eval.hs
diff options
context:
space:
mode:
authorMarvin Borner2022-08-12 15:26:03 +0200
committerMarvin Borner2022-08-12 15:26:03 +0200
commitcce495b3b4440997274ecab3d72ed61d6a50b007 (patch)
treecc56c7af514dd6ca31edb5360a6682ac5439af01 /src/Eval.hs
parentb3cf49974e8af4e35ffc01fbe2f8e181d38de03a (diff)
Added infix operator support
This isn't compatible with the :test .. = .. syntax, therefore I removed it. They also don't have custom precedence/associativity support and aren't chainable right now.
Diffstat (limited to 'src/Eval.hs')
-rw-r--r--src/Eval.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Eval.hs b/src/Eval.hs
index 65db990..6b165b2 100644
--- a/src/Eval.hs
+++ b/src/Eval.hs
@@ -66,11 +66,15 @@ evalApp f g sub =
Right f' -> fmap (Application f') <$> evalExp g sub
)
+evalInfix :: Expression -> String -> Expression -> Environment -> Program (Failable Expression)
+evalInfix le i re = evalExp $ Application (Application (Variable i) le) re
+
evalExp :: Expression -> Environment -> Program (Failable Expression)
evalExp idx@(Bruijn _ ) = const $ pure $ Right idx
evalExp ( Variable var) = evalVar var
evalExp ( Abstraction e) = evalAbs e
evalExp ( Application f g) = evalApp f g
+evalExp (Infix le i re) = evalInfix le i re
evalDefine
:: String -> Expression -> Environment -> Program (Failable Expression)