Skip to content

Commit 506965c

Browse files
committed
move axis into module
1 parent 743cd5b commit 506965c

File tree

5 files changed

+76
-67
lines changed

5 files changed

+76
-67
lines changed

typing/jkind_axis.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module Axis = struct
122122
end
123123

124124
type 'a t =
125-
| Modal : ('a, _, _) Mode.Alloc.axis -> 'a t
125+
| Modal : ('a, _, _) Mode.Alloc.Axis.t -> 'a t
126126
| Nonmodal : 'a Nonmodal.t -> 'a t
127127

128128
type packed = Pack : 'a t -> packed [@@unboxed]
@@ -159,7 +159,7 @@ module Axis = struct
159159
Pack (Nonmodal Nullability) ]
160160

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

typing/jkind_axis.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module Axis : sig
4949

5050
(** Represents an axis of a jkind *)
5151
type 'a t =
52-
| Modal : ('a, _, _) Mode.Alloc.axis -> 'a t
52+
| Modal : ('a, _, _) Mode.Alloc.Axis.t -> 'a t
5353
| Nonmodal : 'a Nonmodal.t -> 'a t
5454

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

typing/mode.ml

+46-39
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,9 @@ module Comonadic_with (Areality : Areality) = struct
20662066

20672067
include Comonadic_gen (Obj)
20682068

2069-
type error = Error : (Obj.const, 'a) C.Axis.t * 'a Solver.error -> error
2069+
type 'a axis = (Obj.const, 'a) C.Axis.t
2070+
2071+
type error = Error : 'a axis * 'a Solver.error -> error
20702072

20712073
type equate_error = equate_step * error
20722074

@@ -2208,7 +2210,9 @@ module Monadic = struct
22082210

22092211
include Monadic_gen (Obj)
22102212

2211-
type error = Error : (Obj.const, 'a) C.Axis.t * 'a Solver.error -> error
2213+
type 'a axis = (Obj.const, 'a) C.Axis.t
2214+
2215+
type error = Error : 'a axis * 'a Solver.error -> error
22122216

22132217
type equate_error = equate_step * error
22142218

@@ -2338,33 +2342,35 @@ module Value_with (Areality : Areality) = struct
23382342

23392343
type lr = (allowed * allowed) t
23402344

2341-
type ('a, 'd0, 'd1) axis =
2342-
| Monadic : (Monadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd neg) axis
2343-
| Comonadic : (Comonadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd pos) axis
2345+
module Axis = struct
2346+
type ('a, 'd0, 'd1) t =
2347+
| Monadic : (Monadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd neg) t
2348+
| Comonadic : (Comonadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd pos) t
23442349

2345-
type axis_packed = P : (_, _, _) axis -> axis_packed
2350+
type packed = P : (_, _, _) t -> packed
23462351

2347-
let print_axis (type a d0 d1) ppf (axis : (a, d0, d1) axis) =
2348-
match axis with
2349-
| Monadic ax -> Axis.print ppf ax
2350-
| Comonadic ax -> Axis.print ppf ax
2352+
let print (type a d0 d1) ppf (t : (a, d0, d1) t) =
2353+
match t with
2354+
| Monadic ax -> Axis.print ppf ax
2355+
| Comonadic ax -> Axis.print ppf ax
2356+
2357+
let all =
2358+
[ P (Comonadic Areality);
2359+
P (Monadic Uniqueness);
2360+
P (Comonadic Linearity);
2361+
P (Monadic Contention);
2362+
P (Comonadic Portability);
2363+
P (Comonadic Statefulness);
2364+
P (Monadic Visibility) ]
2365+
end
23512366

2352-
let lattice_of_axis (type a d0 d1) (axis : (a, d0, d1) axis) :
2367+
let lattice_of_axis (type a d0 d1) (axis : (a, d0, d1) Axis.t) :
23532368
(module Lattice with type t = a) =
23542369
match axis with
23552370
| Comonadic ax -> Comonadic.Const.lattice_of_axis ax
23562371
| Monadic ax -> Monadic.Const.lattice_of_axis ax
23572372

2358-
let all_axes =
2359-
[ P (Comonadic Areality);
2360-
P (Monadic Uniqueness);
2361-
P (Comonadic Linearity);
2362-
P (Monadic Contention);
2363-
P (Comonadic Portability);
2364-
P (Comonadic Statefulness);
2365-
P (Monadic Visibility) ]
2366-
2367-
let proj_obj : type a d0 d1. (a, d0, d1) axis -> a C.obj = function
2373+
let proj_obj : type a d0 d1. (a, d0, d1) Axis.t -> a C.obj = function
23682374
| Monadic ax -> Monadic.proj_obj ax
23692375
| Comonadic ax -> Comonadic.proj_obj ax
23702376

@@ -2604,29 +2610,29 @@ module Value_with (Areality : Areality) = struct
26042610
let monadic = Monadic.min in
26052611
merge { comonadic; monadic }
26062612

2607-
let print_axis : type a. (a, _, _) axis -> _ -> a -> unit =
2613+
let print_axis : type a. (a, _, _) Axis.t -> _ -> a -> unit =
26082614
fun ax ppf a ->
26092615
let obj = proj_obj ax in
26102616
C.print obj ppf a
26112617

2612-
let le_axis : type a d0 d1. (a, d0, d1) axis -> a -> a -> bool =
2618+
let le_axis : type a d0 d1. (a, d0, d1) Axis.t -> a -> a -> bool =
26132619
fun ax m0 m1 ->
26142620
match ax with
26152621
| Comonadic ax -> Comonadic.le_axis ax m0 m1
26162622
| Monadic ax -> Monadic.le_axis ax m0 m1
26172623

2618-
let min_axis : type a d0 d1. (a, d0, d1) axis -> a = function
2624+
let min_axis : type a d0 d1. (a, d0, d1) Axis.t -> a = function
26192625
| Comonadic ax -> Comonadic.min_axis ax
26202626
| Monadic ax -> Monadic.min_axis ax
26212627

2622-
let max_axis : type a d0 d1. (a, d0, d1) axis -> a = function
2628+
let max_axis : type a d0 d1. (a, d0, d1) Axis.t -> a = function
26232629
| Comonadic ax -> Comonadic.max_axis ax
26242630
| Monadic ax -> Monadic.max_axis ax
26252631

2626-
let is_max : type a d0 d1. (a, d0, d1) axis -> a -> bool =
2632+
let is_max : type a d0 d1. (a, d0, d1) Axis.t -> a -> bool =
26272633
fun ax m -> le_axis ax (max_axis ax) m
26282634

2629-
let is_min : type a d0 d1. (a, d0, d1) axis -> a -> bool =
2635+
let is_min : type a d0 d1. (a, d0, d1) Axis.t -> a -> bool =
26302636
fun ax m -> le_axis ax m (min_axis ax)
26312637

26322638
let split = split
@@ -2677,7 +2683,7 @@ module Value_with (Areality : Areality) = struct
26772683
let monadic, b1 = Monadic.newvar_below monadic in
26782684
{ monadic; comonadic }, b0 || b1
26792685

2680-
type error = Error : ('a, _, _) axis * 'a Solver.error -> error
2686+
type error = Error : ('a, _, _) Axis.t * 'a Solver.error -> error
26812687

26822688
type equate_error = equate_step * error
26832689

@@ -2715,7 +2721,7 @@ module Value_with (Areality : Areality) = struct
27152721

27162722
let proj :
27172723
type a l0 l1 r0 r1.
2718-
(a, l0 * r0, l1 * r1) axis -> (l0 * r0) t -> (a, l1 * r1) mode =
2724+
(a, l0 * r0, l1 * r1) Axis.t -> (l0 * r0) t -> (a, l1 * r1) mode =
27192725
fun ax m ->
27202726
match ax with
27212727
| Monadic ax -> proj_monadic ax m
@@ -2735,7 +2741,7 @@ module Value_with (Areality : Areality) = struct
27352741

27362742
let max_with :
27372743
type a l0 l1 r0 r1.
2738-
(a, l0 * r0, l1 * r1) axis -> (a, l1 * r1) mode -> (disallowed * r0) t =
2744+
(a, l0 * r0, l1 * r1) Axis.t -> (a, l1 * r1) mode -> (disallowed * r0) t =
27392745
fun ax m ->
27402746
match ax with
27412747
| Monadic ax -> max_with_monadic ax m
@@ -2755,7 +2761,7 @@ module Value_with (Areality : Areality) = struct
27552761

27562762
let min_with :
27572763
type a l0 l1 r0 r1.
2758-
(a, l0 * r0, l1 * r1) axis -> (a, l1 * r1) mode -> (l0 * disallowed) t =
2764+
(a, l0 * r0, l1 * r1) Axis.t -> (a, l1 * r1) mode -> (l0 * disallowed) t =
27592765
fun ax m ->
27602766
match ax with
27612767
| Monadic ax -> min_with_monadic ax m
@@ -2771,7 +2777,7 @@ module Value_with (Areality : Areality) = struct
27712777

27722778
let join_with :
27732779
type a l0 l1 r0 r1.
2774-
(a, l0 * r0, l1 * r1) axis -> a -> (l0 * r0) t -> (l0 * r0) t =
2780+
(a, l0 * r0, l1 * r1) Axis.t -> a -> (l0 * r0) t -> (l0 * r0) t =
27752781
fun ax c m ->
27762782
match ax with
27772783
| Monadic ax -> join_with_monadic ax c m
@@ -2787,7 +2793,7 @@ module Value_with (Areality : Areality) = struct
27872793

27882794
let meet_with :
27892795
type a l0 r0 l1 r1.
2790-
(a, l0 * r0, l1 * r1) axis -> a -> (l0 * r0) t -> (l0 * r0) t =
2796+
(a, l0 * r0, l1 * r1) Axis.t -> a -> (l0 * r0) t -> (l0 * r0) t =
27912797
fun ax c m ->
27922798
match ax with
27932799
| Monadic ax -> meet_with_monadic ax c m
@@ -2922,7 +2928,7 @@ module Const = struct
29222928
}
29232929

29242930
module Axis = struct
2925-
let alloc_as_value : Alloc.axis_packed -> Value.axis_packed = function
2931+
let alloc_as_value : Alloc.Axis.packed -> Value.Axis.packed = function
29262932
| P (Comonadic Areality) -> P (Comonadic Areality)
29272933
| P (Comonadic Linearity) -> P (Comonadic Linearity)
29282934
| P (Comonadic Portability) -> P (Comonadic Portability)
@@ -2973,7 +2979,7 @@ module Modality = struct
29732979
| Meet_with : 'a -> 'a raw
29742980
| Join_with : 'a -> 'a raw
29752981

2976-
type t = Atom : ('a, _, _) Value.axis * 'a raw -> t
2982+
type t = Atom : ('a, _, _) Value.Axis.t * 'a raw -> t
29772983

29782984
let is_id (Atom (ax, a)) =
29792985
match a with
@@ -2994,7 +3000,7 @@ module Modality = struct
29943000
module Monadic = struct
29953001
module Mode = Value.Monadic
29963002

2997-
type 'a axis = (Mode.Const.t, 'a) Axis.t
3003+
type 'a axis = 'a Mode.axis
29983004

29993005
type error = Error : 'a axis * 'a raw Solver.error -> error
30003006

@@ -3149,7 +3155,7 @@ module Modality = struct
31493155
module Comonadic = struct
31503156
module Mode = Value.Comonadic
31513157

3152-
type 'a axis = (Mode.Const.t, 'a) Axis.t
3158+
type 'a axis = 'a Mode.axis
31533159

31543160
type error = Error : 'a axis * 'a raw Solver.error -> error
31553161

@@ -3307,7 +3313,8 @@ module Modality = struct
33073313
end
33083314

33093315
module Value = struct
3310-
type error = Error : ('a, _, _) Value.axis * 'a raw Solver.error -> error
3316+
type error =
3317+
| Error : ('a, _, _) Value.Axis.t * 'a raw Solver.error -> error
33113318

33123319
type equate_error = equate_step * error
33133320

@@ -3358,7 +3365,7 @@ module Modality = struct
33583365
let to_list { monadic; comonadic } =
33593366
Comonadic.to_list comonadic @ Monadic.to_list monadic
33603367

3361-
let proj (type a d0 d1) (ax : (a, d0, d1) Value.axis)
3368+
let proj (type a d0 d1) (ax : (a, d0, d1) Value.Axis.t)
33623369
{ monadic; comonadic } =
33633370
match ax with
33643371
| Monadic ax -> Monadic.proj ax monadic

typing/mode_intf.mli

+25-23
Original file line numberDiff line numberDiff line change
@@ -414,21 +414,23 @@ module type S = sig
414414
val meet_const : Const.t -> ('l * 'r) t -> ('l * 'r) t
415415
end
416416

417-
(** Represents a mode axis in this product whose constant is ['a], and whose
418-
allowance is ['d1] given the product's allowance ['d0]. *)
419-
type ('a, 'd0, 'd1) axis =
420-
| Monadic : (Monadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd neg) axis
421-
| Comonadic : (Comonadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd pos) axis
417+
module Axis : sig
418+
(** Represents a mode axis in this product whose constant is ['a], and whose
419+
allowance is ['d1] given the product's allowance ['d0]. *)
420+
type ('a, 'd0, 'd1) t =
421+
| Monadic : (Monadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd neg) t
422+
| Comonadic : (Comonadic.Const.t, 'a) Axis.t -> ('a, 'd, 'd pos) t
423+
424+
type packed = P : (_, _, _) t -> packed
422425

423-
type axis_packed = P : (_, _, _) axis -> axis_packed
426+
val print : Format.formatter -> ('a, _, _) t -> unit
424427

425-
val print_axis : Format.formatter -> ('a, _, _) axis -> unit
428+
val all : packed list
429+
end
426430

427431
(** Gets the normal lattice for comonadic axes and the "op"ped lattice for
428432
monadic ones. *)
429-
val lattice_of_axis : ('a, _, _) axis -> (module Lattice with type t = 'a)
430-
431-
val all_axes : axis_packed list
433+
val lattice_of_axis : ('a, _, _) Axis.t -> (module Lattice with type t = 'a)
432434

433435
type ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h) modes =
434436
{ areality : 'a;
@@ -476,9 +478,9 @@ module type S = sig
476478
val print : Format.formatter -> t -> unit
477479
end
478480

479-
val is_max : ('a, _, _) axis -> 'a -> bool
481+
val is_max : ('a, _, _) Axis.t -> 'a -> bool
480482

481-
val is_min : ('a, _, _) axis -> 'a -> bool
483+
val is_min : ('a, _, _) Axis.t -> 'a -> bool
482484

483485
val split : t -> (Monadic.Const.t, Comonadic.Const.t) monadic_comonadic
484486

@@ -495,10 +497,10 @@ module type S = sig
495497
val partial_apply : t -> t
496498

497499
(** Prints a constant on any axis. *)
498-
val print_axis : ('a, _, _) axis -> Format.formatter -> 'a -> unit
500+
val print_axis : ('a, _, _) Axis.t -> Format.formatter -> 'a -> unit
499501
end
500502

501-
type error = Error : ('a, _, _) axis * 'a Solver.error -> error
503+
type error = Error : ('a, _, _) Axis.t * 'a Solver.error -> error
502504

503505
type 'd t = ('d Monadic.t, 'd Comonadic.t) monadic_comonadic
504506

@@ -514,23 +516,23 @@ module type S = sig
514516
end
515517

516518
val proj :
517-
('a, 'l0 * 'r0, 'l1 * 'r1) axis -> ('l0 * 'r0) t -> ('a, 'l1 * 'r1) mode
519+
('a, 'l0 * 'r0, 'l1 * 'r1) Axis.t -> ('l0 * 'r0) t -> ('a, 'l1 * 'r1) mode
518520

519521
val max_with :
520-
('a, 'l0 * 'r0, 'l1 * 'r1) axis ->
522+
('a, 'l0 * 'r0, 'l1 * 'r1) Axis.t ->
521523
('a, 'l1 * 'r1) mode ->
522524
(disallowed * 'r0) t
523525

524526
val min_with :
525-
('a, 'l0 * 'r0, 'l1 * 'r1) axis ->
527+
('a, 'l0 * 'r0, 'l1 * 'r1) Axis.t ->
526528
('a, 'l1 * 'r1) mode ->
527529
('l0 * disallowed) t
528530

529531
val meet_with :
530-
('a, 'l0 * 'r0, 'l1 * 'r1) axis -> 'a -> ('l0 * 'r0) t -> ('l0 * 'r0) t
532+
('a, 'l0 * 'r0, 'l1 * 'r1) Axis.t -> 'a -> ('l0 * 'r0) t -> ('l0 * 'r0) t
531533

532534
val join_with :
533-
('a, 'l0 * 'r0, 'l1 * 'r1) axis -> 'a -> ('l0 * 'r0) t -> ('l0 * 'r0) t
535+
('a, 'l0 * 'r0, 'l1 * 'r1) Axis.t -> 'a -> ('l0 * 'r0) t -> ('l0 * 'r0) t
534536

535537
val zap_to_legacy : lr -> Const.t
536538

@@ -572,7 +574,7 @@ module type S = sig
572574
val alloc_as_value : Alloc.Const.t -> Value.Const.t
573575

574576
module Axis : sig
575-
val alloc_as_value : Alloc.axis_packed -> Value.axis_packed
577+
val alloc_as_value : Alloc.Axis.packed -> Value.Axis.packed
576578
end
577579

578580
val locality_as_regionality : Locality.Const.t -> Regionality.Const.t
@@ -609,7 +611,7 @@ module type S = sig
609611
in which case it's the identity modality. *)
610612

611613
(** An atom modality is a [raw] accompanied by the axis it acts on. *)
612-
type t = Atom : ('a, _, _) Value.axis * 'a raw -> t
614+
type t = Atom : ('a, _, _) Value.Axis.t * 'a raw -> t
613615

614616
(** Test if the given modality is the identity modality. *)
615617
val is_id : t -> bool
@@ -624,7 +626,7 @@ module type S = sig
624626
type atom := t
625627

626628
type error =
627-
| Error : ('a, _, _) Value.axis * 'a raw Solver.error -> error
629+
| Error : ('a, _, _) Value.Axis.t * 'a raw Solver.error -> error
628630

629631
type nonrec equate_error = equate_step * error
630632

@@ -674,7 +676,7 @@ module type S = sig
674676
val of_list : atom list -> t
675677

676678
(** Project out the [atom] for the given axis in the given modality. *)
677-
val proj : ('a, _, _) Value.axis -> t -> atom
679+
val proj : ('a, _, _) Value.Axis.t -> t -> atom
678680

679681
(** [equate t0 t1] checks that [t0 = t1].
680682
Definition: [t0 = t1] iff [t0 <= t1] and [t1 <= t0]. *)

typing/typemode.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exception Error of Location.t * error
2525

2626
module Axis_pair = struct
2727
type 'm t =
28-
| Modal_axis_pair : ('a, _, _) Mode.Alloc.axis * 'a -> modal t
28+
| Modal_axis_pair : ('a, _, _) Mode.Alloc.Axis.t * 'a -> modal t
2929
| Any_axis_pair : 'a Axis.t * 'a -> maybe_nonmodal t
3030
| Everything_but_nullability : maybe_nonmodal t
3131

@@ -265,7 +265,7 @@ let transl_mode_annots annots : Alloc.Const.Option.t =
265265
let step modifiers_so_far annot =
266266
let { txt =
267267
Modal_axis_pair (type a d0 d1)
268-
((axis, mode) : (a, d0, d1) Mode.Alloc.axis * a);
268+
((axis, mode) : (a, d0, d1) Mode.Alloc.Axis.t * a);
269269
loc
270270
} =
271271
transl_annot ~annot_type:Mode ~required_mode_maturity:(Some Stable)

0 commit comments

Comments
 (0)