From 9368bcb9897702ec86277505bf597066ceb83502 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 10 Dec 2022 19:19:05 +0200 Subject: Reimplement Ord instance for ASTNode --- src/Utils.hs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Utils.hs b/src/Utils.hs index 54f1267..f3e2b8c 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -226,12 +226,26 @@ instance (Eq ASTNode) where _ == ASTHole = True _ == _ = False --- Ord instance needed for M.Map +-- Ord instance needed for M.Map and lt? builtin instance (Ord AST) where AST { an = node1 } <= AST { an = node2 } = node1 <= node2 instance (Ord ASTNode) where - _ <= _ = True + ASTInteger a <= ASTInteger b = a <= b + ASTDouble a <= ASTDouble b = a <= b + ASTSymbol a <= ASTSymbol b = a <= b + ASTBoolean a <= ASTBoolean b = a <= b + ASTString a <= ASTString b = a <= b + ASTTag n _ <= ASTTag m _ = n <= m + ASTVector a <= ASTVector b = a <= b + ASTFunctionCall a <= ASTFunctionCall b = a <= b + ASTHashMap a <= ASTHashMap b = a <= b + ASTRecord ah _ hma <= ASTRecord bh _ hmb = ah <= bh && hma <= hmb + ASTAtom a <= ASTAtom b = a <= b + ASTUnit <= ASTUnit = True + ASTHole <= _ = True + _ <= ASTHole = True + _ <= _ = False computeTagNSeed :: W.Word64 computeTagNSeed = 123 -- cgit v1.3