diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-10 19:19:05 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-10 19:19:05 +0200 |
| commit | 9368bcb9897702ec86277505bf597066ceb83502 (patch) | |
| tree | 3813ed52e7f286393ed4a84436f1bcfaa4c527af /src | |
| parent | 8baa85fd4c3607a7b3cebf2518a930a3b8a924bf (diff) | |
Reimplement Ord instance for ASTNode
Diffstat (limited to 'src')
| -rw-r--r-- | src/Utils.hs | 18 |
1 files 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 |
