aboutsummaryrefslogtreecommitdiffstats
path: root/src/Utils.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-09-27 11:11:44 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commit6e55d34719f89192c9141f50638c6dc5bba71dff (patch)
tree33961f9f570b1ff01d0ae11fc6a6c6e3fca2908d /src/Utils.hs
parent83ae25fe87e3a56d169ae8cfc5bf20423d3ec4a5 (diff)
Add holes, builtins, improve matching
Diffstat (limited to 'src/Utils.hs')
-rw-r--r--src/Utils.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Utils.hs b/src/Utils.hs
index 56fd1a2..2b0f271 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -38,6 +38,7 @@ data AST
| ASTHashMap (M.Map AST AST)
| ASTFunction LFunction
| ASTUnit
+ | ASTHole
instance (Show AST) where
show (ASTInteger n) = show n
@@ -52,6 +53,7 @@ instance (Show AST) where
in "{" ++ L.intercalate " " (map show $ flattenMap m) ++ "}"
show (ASTFunction _) = "<fn>"
show ASTUnit = "<unit>"
+ show ASTHole = "<hole>"
instance (Eq AST) where
ASTInteger a == ASTInteger b = a == b
@@ -63,6 +65,8 @@ instance (Eq AST) where
ASTFunctionCall a == ASTFunctionCall b = a == b
ASTHashMap a == ASTHashMap b = a == b
ASTUnit == ASTUnit = True
+ ASTHole == _ = True
+ _ == ASTHole = True
_ == _ = False
instance (Ord AST) where
@@ -75,6 +79,8 @@ instance (Ord AST) where
ASTFunctionCall a <= ASTFunctionCall b = a <= b
ASTHashMap a <= ASTHashMap b = a <= b
ASTUnit <= ASTUnit = True
+ ASTHole <= _ = True
+ _ <= ASTHole = True
_ <= _ = False
assertIsASTFunction :: AST -> LContext AST