Skip to content

Refactor lattice flipping for modes #3949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions typing/allowance.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type right_only = disallowed * allowed

type both = allowed * allowed

type 'a pos = 'b * 'c constraint 'a = 'b * 'c

type 'a neg = 'c * 'b constraint 'a = 'b * 'c

module type Allow_disallow = sig
type ('a, 'b, 'd) sided constraint 'd = 'l * 'r

Expand Down
8 changes: 8 additions & 0 deletions typing/allowance.mli
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ type right_only = disallowed * allowed

type both = allowed * allowed

(** Arrange the permissions appropriately for a positive lattice, by
doing nothing. *)
type 'a pos = 'b * 'c constraint 'a = 'b * 'c

(** Arrange the permissions appropriately for a negative lattice, by
swapping left and right. *)
type 'a neg = 'c * 'b constraint 'a = 'b * 'c

module type Allow_disallow = sig
type ('a, 'b, 'd) sided constraint 'd = 'l * 'r

Expand Down
4 changes: 2 additions & 2 deletions typing/includecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,9 @@ module Record_diffing = struct
| Immutable, Mutable _ -> Some Second
| Mutable m1, Mutable m2 ->
let open Mode.Alloc.Comonadic.Const in
(if not (eq m1 legacy) then
(if not (Misc.Le_result.equal ~le m1 legacy) then
Misc.fatal_errorf "Unexpected mutable(%a)" print m1);
(if not (eq m2 legacy) then
(if not (Misc.Le_result.equal ~le m2 legacy) then
Misc.fatal_errorf "Unexpected mutable(%a)" print m2);
None
in
Expand Down
6 changes: 3 additions & 3 deletions typing/jkind_axis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module Axis = struct
end

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

type packed = Pack : 'a t -> packed [@@unboxed]
Expand All @@ -142,7 +142,7 @@ module Axis = struct

let get (type a) : a t -> (module Axis_ops with type t = a) = function
| Modal axis ->
(module Accent_lattice ((val Mode.Alloc.lattice_of_axis axis)))
(module Accent_lattice ((val Mode.Alloc.Const.lattice_of_axis axis)))
| Nonmodal Externality -> (module Externality)
| Nonmodal Nullability -> (module Nullability)

Expand All @@ -159,7 +159,7 @@ module Axis = struct
Pack (Nonmodal Nullability) ]

let name (type a) : a t -> string = function
| Modal axis -> Format.asprintf "%a" Mode.Alloc.print_axis axis
| Modal axis -> Format.asprintf "%a" Mode.Alloc.Axis.print axis
| Nonmodal Externality -> "externality"
| Nonmodal Nullability -> "nullability"

Expand Down
2 changes: 1 addition & 1 deletion typing/jkind_axis.mli
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Axis : sig

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

type packed = Pack : 'a t -> packed [@@unboxed]
Expand Down
Loading