Skip to content

Commit

Permalink
Add more equality
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Nov 20, 2024
1 parent 8ad5483 commit 4ef6a65
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/haz3lcore/dynamics/FilterAction.re
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type action =
| Step
| Eval;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type count =
| One
| All;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type t = (action, count);

let string_of_t = v => {
Expand Down
2 changes: 1 addition & 1 deletion src/haz3lcore/dynamics/InvalidOperationError.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type t =
| InvalidOfString
| IndexOutOfBounds
Expand Down
7 changes: 6 additions & 1 deletion src/haz3lcore/dynamics/VarBstMap.re
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Inner = {
};

module VarBstMap0 = {
[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type t_('a) = Inner.t('a);

let empty = Inner.empty;
Expand Down Expand Up @@ -61,6 +61,8 @@ module VarBstMap0 = {
let to_list = ctx => ctx |> Inner.to_seq |> List.of_seq;

let of_list = bindings => bindings |> List.to_seq |> Inner.of_seq;

let equal = Inner.equal;
};

module Ordered = {
Expand Down Expand Up @@ -206,6 +208,9 @@ module Ordered = {
let without_keys = (keys, m) => {
filterk(((s, _)) => !List.exists(x => x == s, keys), m);
};

let equal_t_ = (cmp, m1, m2) =>
VarBstMap0.equal(cmp, m1.map, m2.map) && m1.rev_order == m2.rev_order;
};

include VarBstMap0;
2 changes: 2 additions & 0 deletions src/haz3lcore/dynamics/VarBstMap.rei
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,6 @@ module Ordered: {
[without_keys] removes all entires with the given keys from the map
*/
let without_keys: (list(Var.t), t_('a)) => t_('a);

let equal_t_: (('a, 'a) => bool, t_('a), t_('a)) => bool;
};
20 changes: 10 additions & 10 deletions src/haz3lcore/lang/Operators.re
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_un_bool =
| Not;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_un_meta =
| Unquote;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_un_int =
| Minus;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_bin_bool =
| And
| Or;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_bin_int =
| Plus
| Minus
Expand All @@ -29,7 +29,7 @@ type op_bin_int =
| Equals
| NotEquals;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_bin_float =
| Plus
| Minus
Expand All @@ -43,25 +43,25 @@ type op_bin_float =
| Equals
| NotEquals;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_bin_string =
| Concat
| Equals;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_un =
| Meta(op_un_meta)
| Int(op_un_int)
| Bool(op_un_bool);

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type op_bin =
| Int(op_bin_int)
| Float(op_bin_float)
| Bool(op_bin_bool)
| String(op_bin_string);

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type ap_direction =
| Forward
| Reverse;
Expand Down
2 changes: 2 additions & 0 deletions src/haz3lcore/lang/term/IdTagged.re
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type t('a) = {
term: 'a,
};

// TODO This fully ignores ids for equality
let equal = (eq, a, b) => eq(a.term, b.term);
// To be used if you want to remove the id from the debug output
// let pp: ((Format.formatter, 'a) => unit, Format.formatter, t('a)) => unit =
// (fmt_a, formatter, ta) => {
Expand Down
2 changes: 1 addition & 1 deletion src/haz3lcore/statics/Var.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Util;

[@deriving (show({with_path: false}), sexp, yojson)]
[@deriving (show({with_path: false}), sexp, yojson, eq)]
type t = string;

let eq = String.equal;
Expand Down
1 change: 1 addition & 0 deletions src/haz3lcore/tiles/Id.re
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ let t_of_yojson: Yojson.Safe.t => Uuidm.t =

type t = Uuidm.t;

let equal: (t, t) => bool = (==);
let mk: unit => t = Uuidm.v4_gen(Random.State.make_self_init());

let compare: (t, t) => int = Uuidm.compare;
Expand Down

0 comments on commit 4ef6a65

Please sign in to comment.