diff --git a/src/haz3lcore/dune b/src/haz3lcore/dune index 77e2ca3fe1..3579ce73a5 100644 --- a/src/haz3lcore/dune +++ b/src/haz3lcore/dune @@ -10,7 +10,8 @@ js_of_ocaml-ppx ppx_let ppx_sexp_conv - ppx_deriving.show))) + ppx_deriving.show + ppx_deriving.eq))) (env (dev diff --git a/src/haz3lcore/lang/Precedence.re b/src/haz3lcore/lang/Precedence.re index 7d72b66404..23bbc9466f 100644 --- a/src/haz3lcore/lang/Precedence.re +++ b/src/haz3lcore/lang/Precedence.re @@ -3,7 +3,7 @@ open Util; /** * higher precedence means lower int representation */ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = int; let max: t = 0; diff --git a/src/haz3lcore/lang/Sort.re b/src/haz3lcore/lang/Sort.re index 2b66c3282b..c75225e476 100644 --- a/src/haz3lcore/lang/Sort.re +++ b/src/haz3lcore/lang/Sort.re @@ -1,4 +1,4 @@ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Any | Nul diff --git a/src/haz3lcore/tiles/Base.re b/src/haz3lcore/tiles/Base.re index 8c127d83ba..0482defc2c 100644 --- a/src/haz3lcore/tiles/Base.re +++ b/src/haz3lcore/tiles/Base.re @@ -3,7 +3,7 @@ open Util; /* The different kinds of projector. New projectors * types need to be registered here in order to be * able to create and update their instances */ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type kind = | Fold | Info @@ -12,7 +12,7 @@ type kind = | SliderF | TextArea; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type segment = list(piece) and piece = | Tile(tile) @@ -25,6 +25,7 @@ and tile = { // - length(shards) <= length(label) // - length(shards) == length(children) + 1 // - sort(shards) == shards + [@equal (_, _) => true] id: Id.t, label: Label.t, mold: Mold.t, @@ -32,6 +33,7 @@ and tile = { children: list(segment), } and projector = { + [@equal (_, _) => true] id: Id.t, kind, syntax: piece, diff --git a/src/haz3lcore/tiles/Grout.re b/src/haz3lcore/tiles/Grout.re index 496de68f10..9223b293be 100644 --- a/src/haz3lcore/tiles/Grout.re +++ b/src/haz3lcore/tiles/Grout.re @@ -1,6 +1,6 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type shape = | Convex | Concave; @@ -10,7 +10,7 @@ type t = { id: Id.t, shape, }; - +let equal = (a: t, b: t) => a.shape == b.shape; let id = g => g.id; let shapes = g => diff --git a/src/haz3lcore/tiles/Label.re b/src/haz3lcore/tiles/Label.re index e26eeaa5a8..f47994764a 100644 --- a/src/haz3lcore/tiles/Label.re +++ b/src/haz3lcore/tiles/Label.re @@ -1,6 +1,6 @@ open Util; /* A label is the textual expression of a form's delimiters */ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = list(Token.t); exception Empty_label; diff --git a/src/haz3lcore/tiles/Mold.re b/src/haz3lcore/tiles/Mold.re index 743fcb0d18..a40dba0017 100644 --- a/src/haz3lcore/tiles/Mold.re +++ b/src/haz3lcore/tiles/Mold.re @@ -1,6 +1,6 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { out: Sort.t, in_: list(Sort.t), diff --git a/src/haz3lcore/tiles/Nib.re b/src/haz3lcore/tiles/Nib.re index 863ea9bd9f..81c2f2ed65 100644 --- a/src/haz3lcore/tiles/Nib.re +++ b/src/haz3lcore/tiles/Nib.re @@ -1,7 +1,7 @@ open Util; module Shape = { - [@deriving (show({with_path: false}), sexp, yojson)] + [@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Convex | Concave(Precedence.t); @@ -45,7 +45,7 @@ module Shape = { }; }; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { shape: Shape.t, sort: Sort.t, diff --git a/src/haz3lcore/tiles/Nibs.re b/src/haz3lcore/tiles/Nibs.re index 0c4225a279..88df87de86 100644 --- a/src/haz3lcore/tiles/Nibs.re +++ b/src/haz3lcore/tiles/Nibs.re @@ -1,4 +1,4 @@ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = (Nib.t, Nib.t); [@deriving show] diff --git a/src/haz3lcore/tiles/Piece.re b/src/haz3lcore/tiles/Piece.re index fc6207a979..bade3f9a6f 100644 --- a/src/haz3lcore/tiles/Piece.re +++ b/src/haz3lcore/tiles/Piece.re @@ -1,6 +1,6 @@ include Base; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = piece; let secondary = w => Secondary(w); diff --git a/src/haz3lcore/tiles/Secondary.re b/src/haz3lcore/tiles/Secondary.re index c973469254..d075363fa1 100644 --- a/src/haz3lcore/tiles/Secondary.re +++ b/src/haz3lcore/tiles/Secondary.re @@ -1,11 +1,11 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type cls = | Whitespace | Comment; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type secondary_content = | Whitespace(string) | Comment(string); @@ -16,6 +16,7 @@ type t = { content: secondary_content, }; +let equal = (a: t, b: t) => a.content == b.content; let cls_of = (s: t): cls => switch (s.content) { | Whitespace(_) => Whitespace diff --git a/src/haz3lcore/tiles/Segment.re b/src/haz3lcore/tiles/Segment.re index de8689f08a..463c4c643f 100644 --- a/src/haz3lcore/tiles/Segment.re +++ b/src/haz3lcore/tiles/Segment.re @@ -2,7 +2,7 @@ open Util; exception Empty_segment; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = Base.segment; let empty = []; diff --git a/src/haz3lcore/tiles/Token.re b/src/haz3lcore/tiles/Token.re index 8b68de1eb3..33df2d7203 100644 --- a/src/haz3lcore/tiles/Token.re +++ b/src/haz3lcore/tiles/Token.re @@ -1,7 +1,7 @@ open Util; // make an enum -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = string; module Index = { diff --git a/src/haz3lcore/zipper/Ancestor.re b/src/haz3lcore/zipper/Ancestor.re index 498b18b93e..9ae42e30e8 100644 --- a/src/haz3lcore/zipper/Ancestor.re +++ b/src/haz3lcore/zipper/Ancestor.re @@ -2,11 +2,12 @@ open Util; exception Empty_shard_affix; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type step = int; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { + [@equal (_, _) => true] id: Id.t, label: Label.t, mold: Mold.t, diff --git a/src/haz3lcore/zipper/Ancestors.re b/src/haz3lcore/zipper/Ancestors.re index 2acc7d0838..0cf137da54 100644 --- a/src/haz3lcore/zipper/Ancestors.re +++ b/src/haz3lcore/zipper/Ancestors.re @@ -1,9 +1,9 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type generation = (Ancestor.t, Siblings.t); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = list(generation); let empty = []; diff --git a/src/haz3lcore/zipper/Backpack.re b/src/haz3lcore/zipper/Backpack.re index b704e36721..ac45789c9c 100644 --- a/src/haz3lcore/zipper/Backpack.re +++ b/src/haz3lcore/zipper/Backpack.re @@ -203,7 +203,7 @@ module ShardInfo = { }; }; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = list(Selection.t); let empty = []; diff --git a/src/haz3lcore/zipper/Editor.re b/src/haz3lcore/zipper/Editor.re index cd05476fd9..7f44fb54e0 100644 --- a/src/haz3lcore/zipper/Editor.re +++ b/src/haz3lcore/zipper/Editor.re @@ -136,6 +136,7 @@ module State = { meta: Meta.t, }; + let equal = (a: t, b: t) => Zipper.equal(a.zipper, b.zipper); let init = (zipper, ~settings: CoreSettings.t) => { zipper, meta: Meta.init(zipper, ~settings), @@ -148,9 +149,9 @@ module State = { }; module History = { - [@deriving (show({with_path: false}), sexp, yojson)] + [@deriving (show({with_path: false}), sexp, yojson, eq)] type affix = list((Action.t, State.t)); - [@deriving (show({with_path: false}), sexp, yojson)] + [@deriving (show({with_path: false}), sexp, yojson, eq)] type t = (affix, affix); let empty = ([], []); @@ -161,7 +162,7 @@ module History = { ); }; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { state: State.t, history: History.t, diff --git a/src/haz3lcore/zipper/Relatives.re b/src/haz3lcore/zipper/Relatives.re index 251cdbc4e9..65cf81c324 100644 --- a/src/haz3lcore/zipper/Relatives.re +++ b/src/haz3lcore/zipper/Relatives.re @@ -1,6 +1,6 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { siblings: Siblings.t, ancestors: Ancestors.t, diff --git a/src/haz3lcore/zipper/Selection.re b/src/haz3lcore/zipper/Selection.re index 92d6509fb8..4d119ebd8b 100644 --- a/src/haz3lcore/zipper/Selection.re +++ b/src/haz3lcore/zipper/Selection.re @@ -1,16 +1,16 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type buffer = //| Parsed | Unparsed; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type mode = | Normal | Buffer(buffer); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { focus: Direction.t, content: Segment.t, diff --git a/src/haz3lcore/zipper/Siblings.re b/src/haz3lcore/zipper/Siblings.re index 332b63f8df..78d4f17966 100644 --- a/src/haz3lcore/zipper/Siblings.re +++ b/src/haz3lcore/zipper/Siblings.re @@ -1,6 +1,6 @@ open Util; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = (Segment.t, Segment.t); let empty = Segment.(empty, empty); diff --git a/src/haz3lcore/zipper/Zipper.re b/src/haz3lcore/zipper/Zipper.re index f87fb964e6..7f4fd9d799 100644 --- a/src/haz3lcore/zipper/Zipper.re +++ b/src/haz3lcore/zipper/Zipper.re @@ -15,13 +15,13 @@ let init: unit => t = let next_blank = _ => Id.mk(); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type chunkiness = | ByChar | MonoByChar | ByToken; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type planar = | Up | Down diff --git a/src/haz3lcore/zipper/ZipperBase.re b/src/haz3lcore/zipper/ZipperBase.re index cb6311a4b8..ae73d999c3 100644 --- a/src/haz3lcore/zipper/ZipperBase.re +++ b/src/haz3lcore/zipper/ZipperBase.re @@ -1,7 +1,7 @@ open Util; module Caret = { - [@deriving (show({with_path: false}), sexp, yojson)] + [@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Outer | Inner(int, int); @@ -19,7 +19,7 @@ module Caret = { }; // assuming single backpack, shards may appear in selection, backpack, or siblings -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { selection: Selection.t, backpack: Backpack.t, diff --git a/src/haz3lcore/zipper/action/Action.re b/src/haz3lcore/zipper/action/Action.re index 85b24be4f1..be0cacf004 100644 --- a/src/haz3lcore/zipper/action/Action.re +++ b/src/haz3lcore/zipper/action/Action.re @@ -2,7 +2,7 @@ open Util; open Zipper; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type piece_goal = | Grout; @@ -14,28 +14,28 @@ let of_piece_goal = | _ => false ); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type goal = | Point(Point.t) | Piece(piece_goal, Direction.t); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type move = | Extreme(planar) | Local(planar) | Goal(goal); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type jump_target = - | TileId(Id.t) + | TileId([@equal (_, _) => true] Id.t) | BindingSiteOfIndicatedVar; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type rel = | Current - | Id(Id.t, Direction.t); + | Id([@equal (_, _) => true] Id.t, Direction.t); -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type select = | All | Resize(move) @@ -47,27 +47,27 @@ type select = * projectors,as distinguished from external_action, * which defines the actions available internally to all projectors, * and from each projector's own internal action type */ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type project = | SetIndicated(Base.kind) /* Project syntax at caret */ | ToggleIndicated(Base.kind) /* Un/Project syntax at caret */ - | Remove(Id.t) /* Remove projector at Id */ - | SetSyntax(Id.t, Piece.t) /* Set underlying syntax */ - | SetModel(Id.t, string) /* Set serialized projector model */ - | Focus(Id.t, option(Util.Direction.t)) /* Pass control to projector */ - | Escape(Id.t, Direction.t); /* Pass control to parent editor */ + | Remove([@equal (_, _) => true] Id.t) /* Remove projector at Id */ + | SetSyntax([@equal (_, _) => true] Id.t, Piece.t) /* Set underlying syntax */ + | SetModel([@equal (_, _) => true] Id.t, string) /* Set serialized projector model */ + | Focus([@equal (_, _) => true] Id.t, option(Util.Direction.t)) /* Pass control to projector */ + | Escape([@equal (_, _) => true] Id.t, Direction.t); /* Pass control to parent editor */ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type agent = | TyDi; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type buffer = | Set(agent) | Clear | Accept; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Reparse | Buffer(buffer) @@ -87,7 +87,7 @@ type t = | Put_down; module Failure = { - [@deriving (show({with_path: false}), sexp, yojson)] + [@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Cant_move | Cant_insert diff --git a/src/util/Direction.re b/src/util/Direction.re index b59b7faac0..7b611423ad 100644 --- a/src/util/Direction.re +++ b/src/util/Direction.re @@ -1,4 +1,4 @@ -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = | Left | Right; diff --git a/src/util/Point.re b/src/util/Point.re index 6a8f80b698..cc2249c41d 100644 --- a/src/util/Point.re +++ b/src/util/Point.re @@ -1,12 +1,12 @@ open Sexplib.Std; open Ppx_yojson_conv_lib.Yojson_conv; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type row = int; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type col = int; -[@deriving (show({with_path: false}), sexp, yojson)] +[@deriving (show({with_path: false}), sexp, yojson, eq)] type t = { row, col, diff --git a/src/util/dune b/src/util/dune index a3494db579..3e1c9ab3cd 100644 --- a/src/util/dune +++ b/src/util/dune @@ -8,7 +8,8 @@ js_of_ocaml-ppx ppx_let ppx_sexp_conv - ppx_deriving.show))) + ppx_deriving.show + ppx_deriving.eq))) (env (dev