Skip to content

Commit 3a8999d

Browse files
authored
Refactor lattice flipping for modes (#3949)
1 parent b72b2c9 commit 3a8999d

12 files changed

+474
-641
lines changed

typing/allowance.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type right_only = disallowed * allowed
2222

2323
type both = allowed * allowed
2424

25+
type 'a pos = 'b * 'c constraint 'a = 'b * 'c
26+
27+
type 'a neg = 'c * 'b constraint 'a = 'b * 'c
28+
2529
module type Allow_disallow = sig
2630
type ('a, 'b, 'd) sided constraint 'd = 'l * 'r
2731

typing/allowance.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ type right_only = disallowed * allowed
4747

4848
type both = allowed * allowed
4949

50+
(** Arrange the permissions appropriately for a positive lattice, by
51+
doing nothing. *)
52+
type 'a pos = 'b * 'c constraint 'a = 'b * 'c
53+
54+
(** Arrange the permissions appropriately for a negative lattice, by
55+
swapping left and right. *)
56+
type 'a neg = 'c * 'b constraint 'a = 'b * 'c
57+
5058
module type Allow_disallow = sig
5159
type ('a, 'b, 'd) sided constraint 'd = 'l * 'r
5260

typing/includecore.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ module Record_diffing = struct
692692
| Immutable, Mutable _ -> Some Second
693693
| Mutable m1, Mutable m2 ->
694694
let open Mode.Alloc.Comonadic.Const in
695-
(if not (eq m1 legacy) then
695+
(if not (Misc.Le_result.equal ~le m1 legacy) then
696696
Misc.fatal_errorf "Unexpected mutable(%a)" print m1);
697-
(if not (eq m2 legacy) then
697+
(if not (Misc.Le_result.equal ~le m2 legacy) then
698698
Misc.fatal_errorf "Unexpected mutable(%a)" print m2);
699699
None
700700
in

typing/jkind_axis.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ module Axis = struct
177177
end
178178

179179
type 'a t =
180-
| Modal : ('m, 'a, 'd) Mode.Alloc.axis -> 'a t
180+
| Modal : ('a, _, _) Mode.Alloc.Axis.t -> 'a t
181181
| Nonmodal : 'a Nonmodal.t -> 'a t
182182

183183
type packed = Pack : 'a t -> packed [@@unboxed]
@@ -197,7 +197,7 @@ module Axis = struct
197197

198198
let get (type a) : a t -> (module Axis_ops with type t = a) = function
199199
| Modal axis ->
200-
(module Accent_lattice ((val Mode.Alloc.lattice_of_axis axis)))
200+
(module Accent_lattice ((val Mode.Alloc.Const.lattice_of_axis axis)))
201201
| Nonmodal Externality -> (module Externality)
202202
| Nonmodal Nullability -> (module Nullability)
203203
| Nonmodal Separability -> (module Separability)
@@ -216,7 +216,7 @@ module Axis = struct
216216
Pack (Nonmodal Separability) ]
217217

218218
let name (type a) : a t -> string = function
219-
| Modal axis -> Format.asprintf "%a" Mode.Alloc.print_axis axis
219+
| Modal axis -> Format.asprintf "%a" Mode.Alloc.Axis.print axis
220220
| Nonmodal Externality -> "externality"
221221
| Nonmodal Nullability -> "nullability"
222222
| Nonmodal Separability -> "separability"

typing/jkind_axis.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module Axis : sig
5959

6060
(** Represents an axis of a jkind *)
6161
type 'a t =
62-
| Modal : ('m, 'a, 'd) Mode.Alloc.axis -> 'a t
62+
| Modal : ('a, _, _) Mode.Alloc.Axis.t -> 'a t
6363
| Nonmodal : 'a Nonmodal.t -> 'a t
6464

6565
type packed = Pack : 'a t -> packed [@@unboxed]

0 commit comments

Comments
 (0)