From 141db078408f94c410508970d07382d4a6087f17 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 15 Mar 2024 10:20:31 +0100 Subject: Added eq and hash functions in the Ast.Expression --- lib/syntax/t.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/syntax/t.ml') diff --git a/lib/syntax/t.ml b/lib/syntax/t.ml index cb9c7ce..882a375 100644 --- a/lib/syntax/t.ml +++ b/lib/syntax/t.ml @@ -7,6 +7,13 @@ type 'a literal = Text of string | Expression of 'a let map_litteral : f:('a -> 'b) -> 'a literal -> 'b literal = fun ~f -> function Text t -> Text t | Expression e -> Expression (f e) +let eq_literal : eq:('a -> 'a -> bool) -> 'a literal -> 'a literal -> bool = + fun ~eq l1 l2 -> + match (l1, l2) with + | Text s1, Text s2 -> String.equal s1 s2 + | Expression e1, Expression e2 -> eq e1 e2 + | _ -> false + type boperator = | Eq | Neq -- cgit v1.2.3