jon.recoil.org

Source file modes_lib_intf.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
module Definitions = struct
  type monadicity =
    | Comonadic
    | Monadic
  [@@deriving_inline sexp_of]

  let _ = fun (_ : monadicity) -> ()

  let sexp_of_monadicity =
    (function
     | Comonadic -> Sexplib0.Sexp.Atom "Comonadic"
     | Monadic -> Sexplib0.Sexp.Atom "Monadic"
     : monadicity -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_monadicity

  [@@@end]

  (** Modal axes *)

  type locality =
    | Global
    | Local
  [@@deriving_inline sexp_of]

  let _ = fun (_ : locality) -> ()

  let sexp_of_locality =
    (function
     | Global -> Sexplib0.Sexp.Atom "Global"
     | Local -> Sexplib0.Sexp.Atom "Local"
     : locality -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_locality

  [@@@end]

  type portability =
    | Portable
    | Shareable
    | Nonportable
  [@@deriving_inline sexp_of]

  let _ = fun (_ : portability) -> ()

  let sexp_of_portability =
    (function
     | Portable -> Sexplib0.Sexp.Atom "Portable"
     | Shareable -> Sexplib0.Sexp.Atom "Shareable"
     | Nonportable -> Sexplib0.Sexp.Atom "Nonportable"
     : portability -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_portability

  [@@@end]

  type contention =
    | Uncontended
    | Shared
    | Contended
  [@@deriving_inline sexp_of]

  let _ = fun (_ : contention) -> ()

  let sexp_of_contention =
    (function
     | Uncontended -> Sexplib0.Sexp.Atom "Uncontended"
     | Shared -> Sexplib0.Sexp.Atom "Shared"
     | Contended -> Sexplib0.Sexp.Atom "Contended"
     : contention -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_contention

  [@@@end]

  type statefulness =
    | Stateless
    | Reading
    | Stateful
  [@@deriving_inline sexp_of]

  let _ = fun (_ : statefulness) -> ()

  let sexp_of_statefulness =
    (function
     | Stateless -> Sexplib0.Sexp.Atom "Stateless"
     | Reading -> Sexplib0.Sexp.Atom "Reading"
     | Stateful -> Sexplib0.Sexp.Atom "Stateful"
     : statefulness -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_statefulness

  [@@@end]

  type visibility =
    | Read_write
    | Read
    | Immutable
  [@@deriving_inline sexp_of]

  let _ = fun (_ : visibility) -> ()

  let sexp_of_visibility =
    (function
     | Read_write -> Sexplib0.Sexp.Atom "Read_write"
     | Read -> Sexplib0.Sexp.Atom "Read"
     | Immutable -> Sexplib0.Sexp.Atom "Immutable"
     : visibility -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_visibility

  [@@@end]

  type linearity =
    | Many
    | Once
  [@@deriving_inline sexp_of]

  let _ = fun (_ : linearity) -> ()

  let sexp_of_linearity =
    (function
     | Many -> Sexplib0.Sexp.Atom "Many"
     | Once -> Sexplib0.Sexp.Atom "Once"
     : linearity -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_linearity

  [@@@end]

  type uniqueness =
    | Unique
    | Aliased
  [@@deriving_inline sexp_of]

  let _ = fun (_ : uniqueness) -> ()

  let sexp_of_uniqueness =
    (function
     | Unique -> Sexplib0.Sexp.Atom "Unique"
     | Aliased -> Sexplib0.Sexp.Atom "Aliased"
     : uniqueness -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_uniqueness

  [@@@end]

  type yielding =
    | Unyielding
    | Yielding
  [@@deriving_inline sexp_of]

  let _ = fun (_ : yielding) -> ()

  let sexp_of_yielding =
    (function
     | Unyielding -> Sexplib0.Sexp.Atom "Unyielding"
     | Yielding -> Sexplib0.Sexp.Atom "Yielding"
     : yielding -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_yielding

  [@@@end]

  type forkable =
    | Forkable
    | Unforkable
  [@@deriving_inline sexp_of]

  let _ = fun (_ : forkable) -> ()

  let sexp_of_forkable =
    (function
     | Forkable -> Sexplib0.Sexp.Atom "Forkable"
     | Unforkable -> Sexplib0.Sexp.Atom "Unforkable"
     : forkable -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_forkable

  [@@@end]

  type staticity =
    | Static
    | Dynamic
  [@@deriving_inline sexp_of]

  let _ = fun (_ : staticity) -> ()

  let sexp_of_staticity =
    (function
     | Static -> Sexplib0.Sexp.Atom "Static"
     | Dynamic -> Sexplib0.Sexp.Atom "Dynamic"
     : staticity -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_staticity

  [@@@end]

  (** Nonmodal jkind axes (soon to be nontrivialities) *)

  type externality =
    | External_
    | External64
    | Internal
  [@@deriving_inline sexp_of]

  let _ = fun (_ : externality) -> ()

  let sexp_of_externality =
    (function
     | External_ -> Sexplib0.Sexp.Atom "External_"
     | External64 -> Sexplib0.Sexp.Atom "External64"
     | Internal -> Sexplib0.Sexp.Atom "Internal"
     : externality -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_externality

  [@@@end]

  type nullability =
    | Non_null
    | Maybe_null
  [@@deriving_inline sexp_of]

  let _ = fun (_ : nullability) -> ()

  let sexp_of_nullability =
    (function
     | Non_null -> Sexplib0.Sexp.Atom "Non_null"
     | Maybe_null -> Sexplib0.Sexp.Atom "Maybe_null"
     : nullability -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_nullability

  [@@@end]

  type separability =
    | Non_pointer
    | Non_pointer64
    | Non_float
    | Separable
    | Maybe_separable
  [@@deriving_inline sexp_of]

  let _ = fun (_ : separability) -> ()

  let sexp_of_separability =
    (function
     | Non_pointer -> Sexplib0.Sexp.Atom "Non_pointer"
     | Non_pointer64 -> Sexplib0.Sexp.Atom "Non_pointer64"
     | Non_float -> Sexplib0.Sexp.Atom "Non_float"
     | Separable -> Sexplib0.Sexp.Atom "Separable"
     | Maybe_separable -> Sexplib0.Sexp.Atom "Maybe_separable"
     : separability -> Sexplib0.Sexp.t)
  ;;

  let _ = sexp_of_separability

  [@@@end]
  [@@@ocamlformat "disable"]

  type !'a[@phantom] axis =
    | Locality : locality axis
    | Portability : portability axis
    | Contention : contention axis
    | Statefulness : statefulness axis
    | Visibility : visibility axis
    | Linearity : linearity axis
    | Uniqueness : uniqueness axis
    | Yielding : yielding axis
    | Forkable : forkable axis
    | Staticity : staticity axis
  [@@deriving_inline sexp_of]

  let _ = fun (_ : 'a axis) -> ()

  let sexp_of_axis : 'a . 'a axis -> Sexplib0.Sexp.t =
    fun (type a__002_) ->
    (function
      | Locality -> Sexplib0.Sexp.Atom "Locality"
      | Portability -> Sexplib0.Sexp.Atom "Portability"
      | Contention -> Sexplib0.Sexp.Atom "Contention"
      | Statefulness -> Sexplib0.Sexp.Atom "Statefulness"
      | Visibility -> Sexplib0.Sexp.Atom "Visibility"
      | Linearity -> Sexplib0.Sexp.Atom "Linearity"
      | Uniqueness -> Sexplib0.Sexp.Atom "Uniqueness"
      | Yielding -> Sexplib0.Sexp.Atom "Yielding"
      | Forkable -> Sexplib0.Sexp.Atom "Forkable"
      | Staticity -> Sexplib0.Sexp.Atom "Staticity"
                      : a__002_ axis -> Sexplib0.Sexp.t)

  let _ = sexp_of_axis

  [@@@end]
  [@@@ocamlformat "enable"]

  type !'a nonmodal_axis =
    | Externality : externality nonmodal_axis
    | Nullability : nullability nonmodal_axis
    | Separability : separability nonmodal_axis

  type !'a jkind_axis =
    | Modal of 'a axis
    | Nonmodal of 'a nonmodal_axis

  module Modal = struct
    type t =
      | Global
      | Local
      | Portable
      | Shareable
      | Nonportable
      | Uncontended
      | Shared
      | Contended
      | Stateless
      | Reading
      | Stateful
      | Read_write
      | Read
      | Immutable
      | Many
      | Once
      | Unique
      | Aliased
      | Unyielding
      | Yielding
      | Forkable
      | Unforkable
      | Static
      | Dynamic
    [@@deriving_inline enumerate, sexp]

    let _ = fun (_ : t) -> ()

    let all =
      ([ Global
       ; Local
       ; Portable
       ; Shareable
       ; Nonportable
       ; Uncontended
       ; Shared
       ; Contended
       ; Stateless
       ; Reading
       ; Stateful
       ; Read_write
       ; Read
       ; Immutable
       ; Many
       ; Once
       ; Unique
       ; Aliased
       ; Unyielding
       ; Yielding
       ; Forkable
       ; Unforkable
       ; Static
       ; Dynamic
       ]
       : t list)
    ;;

    let _ = all

    let t_of_sexp =
      (let error_source__005_ = "modes_lib_intf.ml.Definitions.Modal.t" in
       function
       | Sexplib0.Sexp.Atom ("global" | "Global") -> Global
       | Sexplib0.Sexp.Atom ("local" | "Local") -> Local
       | Sexplib0.Sexp.Atom ("portable" | "Portable") -> Portable
       | Sexplib0.Sexp.Atom ("shareable" | "Shareable") -> Shareable
       | Sexplib0.Sexp.Atom ("nonportable" | "Nonportable") -> Nonportable
       | Sexplib0.Sexp.Atom ("uncontended" | "Uncontended") -> Uncontended
       | Sexplib0.Sexp.Atom ("shared" | "Shared") -> Shared
       | Sexplib0.Sexp.Atom ("contended" | "Contended") -> Contended
       | Sexplib0.Sexp.Atom ("stateless" | "Stateless") -> Stateless
       | Sexplib0.Sexp.Atom ("reading" | "Reading") -> Reading
       | Sexplib0.Sexp.Atom ("stateful" | "Stateful") -> Stateful
       | Sexplib0.Sexp.Atom ("read_write" | "Read_write") -> Read_write
       | Sexplib0.Sexp.Atom ("read" | "Read") -> Read
       | Sexplib0.Sexp.Atom ("immutable" | "Immutable") -> Immutable
       | Sexplib0.Sexp.Atom ("many" | "Many") -> Many
       | Sexplib0.Sexp.Atom ("once" | "Once") -> Once
       | Sexplib0.Sexp.Atom ("unique" | "Unique") -> Unique
       | Sexplib0.Sexp.Atom ("aliased" | "Aliased") -> Aliased
       | Sexplib0.Sexp.Atom ("unyielding" | "Unyielding") -> Unyielding
       | Sexplib0.Sexp.Atom ("yielding" | "Yielding") -> Yielding
       | Sexplib0.Sexp.Atom ("forkable" | "Forkable") -> Forkable
       | Sexplib0.Sexp.Atom ("unforkable" | "Unforkable") -> Unforkable
       | Sexplib0.Sexp.Atom ("static" | "Static") -> Static
       | Sexplib0.Sexp.Atom ("dynamic" | "Dynamic") -> Dynamic
       | Sexplib0.Sexp.List
           (Sexplib0.Sexp.Atom
              ( "global"
              | "Global"
              | "local"
              | "Local"
              | "portable"
              | "Portable"
              | "shareable"
              | "Shareable"
              | "nonportable"
              | "Nonportable"
              | "uncontended"
              | "Uncontended"
              | "shared"
              | "Shared"
              | "contended"
              | "Contended"
              | "stateless"
              | "Stateless"
              | "reading"
              | "Reading"
              | "stateful"
              | "Stateful"
              | "read_write"
              | "Read_write"
              | "read"
              | "Read"
              | "immutable"
              | "Immutable"
              | "many"
              | "Many"
              | "once"
              | "Once"
              | "unique"
              | "Unique"
              | "aliased"
              | "Aliased"
              | "unyielding"
              | "Unyielding"
              | "yielding"
              | "Yielding"
              | "forkable"
              | "Forkable"
              | "unforkable"
              | "Unforkable"
              | "static"
              | "Static"
              | "dynamic"
              | "Dynamic" )
           :: _) as sexp__006_ ->
         Sexplib0.Sexp_conv_error.stag_no_args error_source__005_ sexp__006_
       | Sexplib0.Sexp.List (Sexplib0.Sexp.List _ :: _) as sexp__004_ ->
         Sexplib0.Sexp_conv_error.nested_list_invalid_sum error_source__005_ sexp__004_
       | Sexplib0.Sexp.List [] as sexp__004_ ->
         Sexplib0.Sexp_conv_error.empty_list_invalid_sum error_source__005_ sexp__004_
       | sexp__004_ ->
         Sexplib0.Sexp_conv_error.unexpected_stag
           error_source__005_
           [ "Global"
           ; "Local"
           ; "Portable"
           ; "Shareable"
           ; "Nonportable"
           ; "Uncontended"
           ; "Shared"
           ; "Contended"
           ; "Stateless"
           ; "Reading"
           ; "Stateful"
           ; "Read_write"
           ; "Read"
           ; "Immutable"
           ; "Many"
           ; "Once"
           ; "Unique"
           ; "Aliased"
           ; "Unyielding"
           ; "Yielding"
           ; "Forkable"
           ; "Unforkable"
           ; "Static"
           ; "Dynamic"
           ]
           sexp__004_
       : Sexplib0.Sexp.t -> t)
    ;;

    let _ = t_of_sexp

    let sexp_of_t =
      (function
       | Global -> Sexplib0.Sexp.Atom "Global"
       | Local -> Sexplib0.Sexp.Atom "Local"
       | Portable -> Sexplib0.Sexp.Atom "Portable"
       | Shareable -> Sexplib0.Sexp.Atom "Shareable"
       | Nonportable -> Sexplib0.Sexp.Atom "Nonportable"
       | Uncontended -> Sexplib0.Sexp.Atom "Uncontended"
       | Shared -> Sexplib0.Sexp.Atom "Shared"
       | Contended -> Sexplib0.Sexp.Atom "Contended"
       | Stateless -> Sexplib0.Sexp.Atom "Stateless"
       | Reading -> Sexplib0.Sexp.Atom "Reading"
       | Stateful -> Sexplib0.Sexp.Atom "Stateful"
       | Read_write -> Sexplib0.Sexp.Atom "Read_write"
       | Read -> Sexplib0.Sexp.Atom "Read"
       | Immutable -> Sexplib0.Sexp.Atom "Immutable"
       | Many -> Sexplib0.Sexp.Atom "Many"
       | Once -> Sexplib0.Sexp.Atom "Once"
       | Unique -> Sexplib0.Sexp.Atom "Unique"
       | Aliased -> Sexplib0.Sexp.Atom "Aliased"
       | Unyielding -> Sexplib0.Sexp.Atom "Unyielding"
       | Yielding -> Sexplib0.Sexp.Atom "Yielding"
       | Forkable -> Sexplib0.Sexp.Atom "Forkable"
       | Unforkable -> Sexplib0.Sexp.Atom "Unforkable"
       | Static -> Sexplib0.Sexp.Atom "Static"
       | Dynamic -> Sexplib0.Sexp.Atom "Dynamic"
       : t -> Sexplib0.Sexp.t)
    ;;

    let _ = sexp_of_t

    [@@@end]
  end

  module type Wrapper = sig
    type 'a t = private 'a

    val mk : 'a -> 'a t
    val unwrap : 'a t -> 'a
    val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
  end

  module Nonmodal = struct
    type t =
      | External_
      | External64
      | Internal
      | Non_null
      | Maybe_null
      | Non_pointer
      | Non_pointer64
      | Non_float
      | Separable
      | Maybe_separable
    [@@deriving_inline enumerate, sexp]

    let _ = fun (_ : t) -> ()

    let all =
      ([ External_
       ; External64
       ; Internal
       ; Non_null
       ; Maybe_null
       ; Non_pointer
       ; Non_pointer64
       ; Non_float
       ; Separable
       ; Maybe_separable
       ]
       : t list)
    ;;

    let _ = all

    let t_of_sexp =
      (let error_source__009_ = "modes_lib_intf.ml.Definitions.Nonmodal.t" in
       function
       | Sexplib0.Sexp.Atom ("external_" | "External_") -> External_
       | Sexplib0.Sexp.Atom ("external64" | "External64") -> External64
       | Sexplib0.Sexp.Atom ("internal" | "Internal") -> Internal
       | Sexplib0.Sexp.Atom ("non_null" | "Non_null") -> Non_null
       | Sexplib0.Sexp.Atom ("maybe_null" | "Maybe_null") -> Maybe_null
       | Sexplib0.Sexp.Atom ("non_pointer" | "Non_pointer") -> Non_pointer
       | Sexplib0.Sexp.Atom ("non_pointer64" | "Non_pointer64") -> Non_pointer64
       | Sexplib0.Sexp.Atom ("non_float" | "Non_float") -> Non_float
       | Sexplib0.Sexp.Atom ("separable" | "Separable") -> Separable
       | Sexplib0.Sexp.Atom ("maybe_separable" | "Maybe_separable") -> Maybe_separable
       | Sexplib0.Sexp.List
           (Sexplib0.Sexp.Atom
              ( "external_"
              | "External_"
              | "external64"
              | "External64"
              | "internal"
              | "Internal"
              | "non_null"
              | "Non_null"
              | "maybe_null"
              | "Maybe_null"
              | "non_pointer"
              | "Non_pointer"
              | "non_pointer64"
              | "Non_pointer64"
              | "non_float"
              | "Non_float"
              | "separable"
              | "Separable"
              | "maybe_separable"
              | "Maybe_separable" )
           :: _) as sexp__010_ ->
         Sexplib0.Sexp_conv_error.stag_no_args error_source__009_ sexp__010_
       | Sexplib0.Sexp.List (Sexplib0.Sexp.List _ :: _) as sexp__008_ ->
         Sexplib0.Sexp_conv_error.nested_list_invalid_sum error_source__009_ sexp__008_
       | Sexplib0.Sexp.List [] as sexp__008_ ->
         Sexplib0.Sexp_conv_error.empty_list_invalid_sum error_source__009_ sexp__008_
       | sexp__008_ ->
         Sexplib0.Sexp_conv_error.unexpected_stag
           error_source__009_
           [ "External_"
           ; "External64"
           ; "Internal"
           ; "Non_null"
           ; "Maybe_null"
           ; "Non_pointer"
           ; "Non_pointer64"
           ; "Non_float"
           ; "Separable"
           ; "Maybe_separable"
           ]
           sexp__008_
       : Sexplib0.Sexp.t -> t)
    ;;

    let _ = t_of_sexp

    let sexp_of_t =
      (function
       | External_ -> Sexplib0.Sexp.Atom "External_"
       | External64 -> Sexplib0.Sexp.Atom "External64"
       | Internal -> Sexplib0.Sexp.Atom "Internal"
       | Non_null -> Sexplib0.Sexp.Atom "Non_null"
       | Maybe_null -> Sexplib0.Sexp.Atom "Maybe_null"
       | Non_pointer -> Sexplib0.Sexp.Atom "Non_pointer"
       | Non_pointer64 -> Sexplib0.Sexp.Atom "Non_pointer64"
       | Non_float -> Sexplib0.Sexp.Atom "Non_float"
       | Separable -> Sexplib0.Sexp.Atom "Separable"
       | Maybe_separable -> Sexplib0.Sexp.Atom "Maybe_separable"
       : t -> Sexplib0.Sexp.t)
    ;;

    let _ = sexp_of_t

    [@@@end]
  end

  module Jkind_mod = struct
    type t =
      | Modal of Modal.t
      | Nonmodal of Nonmodal.t
  end

  module type Lattice = sig
    type t

    val top : t
    val bottom : t
    val join : t -> t -> t
    val meet : t -> t -> t
    val le : t -> t -> bool
    val equal : t -> t -> bool
  end

  module type Axis = sig
    include Lattice

    val all : t list
    val monadicity : monadicity
    val legacy : t
    val of_modal : Modal.t -> t option
    val to_modal : t -> Modal.t

    (** Implementations of [Axis] must provide a total order over its elements. [compare]
        should agree naturally with [le] and [equal]. *)
    val compare : t -> t -> int

    val sexp_of_t : t -> Sexplib0.Sexp.t

    (*_ filled in later with concrete types *)
    type 'a mode
    type 'a modality
    type 'a crossing

    val apply_modality : t modality -> t mode -> t mode

    (** [cross crossing mode] strengthens [mode] as it would on a variable of kind
        [_ mod crossing].

        In the compiler, this is known as [cross_left]. *)
    val cross : t crossing -> t mode -> t mode

    (** [uncross crossing mode] is the weakest mode [mode'] such that
        [cross crossing mode'] is at least as strong as [mode]. It acts as a sort of
        inverse to [cross].

        In the compiler, this is known as [cross_right]. *)
    val uncross : t crossing -> t mode -> t mode
  end

  module type Per_axis = sig
    type 'a wrapped

    type t =
      { locality : locality wrapped
      ; portability : portability wrapped
      ; contention : contention wrapped
      ; statefulness : statefulness wrapped
      ; visibility : visibility wrapped
      ; linearity : linearity wrapped
      ; uniqueness : uniqueness wrapped
      ; yielding : yielding wrapped
      ; forkable : forkable wrapped
      ; staticity : staticity wrapped
      }

    val sexp_of_t : t -> Sexplib0.Sexp.t

    type make_f = { f : 'a. 'a axis -> 'a wrapped }

    val make : make_f -> t
    val get : t -> 'a axis -> 'a wrapped
    val set : t -> 'a axis -> 'a wrapped -> t
  end

  module type Nonmodal_axis = sig
    include Lattice

    val all : t list
    val of_nonmodal : Nonmodal.t -> t option
    val to_nonmodal : t -> Nonmodal.t
  end

  module Nonmodals = struct
    type t =
      { externality : externality
      ; nullability : nullability
      ; separability : separability
      }
    [@@deriving_inline sexp_of]

    let _ = fun (_ : t) -> ()

    let sexp_of_t =
      (fun { externality = externality__012_
           ; nullability = nullability__014_
           ; separability = separability__016_
           } ->
         let bnds__011_ = ([] : _ Stdlib.List.t) in
         let bnds__011_ =
           let arg__017_ = sexp_of_separability separability__016_ in
           (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "separability"; arg__017_ ]
            :: bnds__011_
            : _ Stdlib.List.t)
         in
         let bnds__011_ =
           let arg__015_ = sexp_of_nullability nullability__014_ in
           (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "nullability"; arg__015_ ]
            :: bnds__011_
            : _ Stdlib.List.t)
         in
         let bnds__011_ =
           let arg__013_ = sexp_of_externality externality__012_ in
           (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "externality"; arg__013_ ]
            :: bnds__011_
            : _ Stdlib.List.t)
         in
         Sexplib0.Sexp.List bnds__011_
       : t -> Sexplib0.Sexp.t)
    ;;

    let _ = sexp_of_t

    [@@@end]
  end

  module Base_sort = struct
    type t =
      | Void
      | Value
      | Untagged_immediate
      | Float64
      | Float32
      | Word
      | Bits8
      | Bits16
      | Bits32
      | Bits64
      | Vec128
      | Vec256
      | Vec512
    [@@deriving_inline sexp]

    let _ = fun (_ : t) -> ()

    let t_of_sexp =
      (let error_source__020_ = "modes_lib_intf.ml.Definitions.Base_sort.t" in
       function
       | Sexplib0.Sexp.Atom ("void" | "Void") -> Void
       | Sexplib0.Sexp.Atom ("value" | "Value") -> Value
       | Sexplib0.Sexp.Atom ("untagged_immediate" | "Untagged_immediate") ->
         Untagged_immediate
       | Sexplib0.Sexp.Atom ("float64" | "Float64") -> Float64
       | Sexplib0.Sexp.Atom ("float32" | "Float32") -> Float32
       | Sexplib0.Sexp.Atom ("word" | "Word") -> Word
       | Sexplib0.Sexp.Atom ("bits8" | "Bits8") -> Bits8
       | Sexplib0.Sexp.Atom ("bits16" | "Bits16") -> Bits16
       | Sexplib0.Sexp.Atom ("bits32" | "Bits32") -> Bits32
       | Sexplib0.Sexp.Atom ("bits64" | "Bits64") -> Bits64
       | Sexplib0.Sexp.Atom ("vec128" | "Vec128") -> Vec128
       | Sexplib0.Sexp.Atom ("vec256" | "Vec256") -> Vec256
       | Sexplib0.Sexp.Atom ("vec512" | "Vec512") -> Vec512
       | Sexplib0.Sexp.List
           (Sexplib0.Sexp.Atom
              ( "void"
              | "Void"
              | "value"
              | "Value"
              | "untagged_immediate"
              | "Untagged_immediate"
              | "float64"
              | "Float64"
              | "float32"
              | "Float32"
              | "word"
              | "Word"
              | "bits8"
              | "Bits8"
              | "bits16"
              | "Bits16"
              | "bits32"
              | "Bits32"
              | "bits64"
              | "Bits64"
              | "vec128"
              | "Vec128"
              | "vec256"
              | "Vec256"
              | "vec512"
              | "Vec512" )
           :: _) as sexp__021_ ->
         Sexplib0.Sexp_conv_error.stag_no_args error_source__020_ sexp__021_
       | Sexplib0.Sexp.List (Sexplib0.Sexp.List _ :: _) as sexp__019_ ->
         Sexplib0.Sexp_conv_error.nested_list_invalid_sum error_source__020_ sexp__019_
       | Sexplib0.Sexp.List [] as sexp__019_ ->
         Sexplib0.Sexp_conv_error.empty_list_invalid_sum error_source__020_ sexp__019_
       | sexp__019_ ->
         Sexplib0.Sexp_conv_error.unexpected_stag
           error_source__020_
           [ "Void"
           ; "Value"
           ; "Untagged_immediate"
           ; "Float64"
           ; "Float32"
           ; "Word"
           ; "Bits8"
           ; "Bits16"
           ; "Bits32"
           ; "Bits64"
           ; "Vec128"
           ; "Vec256"
           ; "Vec512"
           ]
           sexp__019_
       : Sexplib0.Sexp.t -> t)
    ;;

    let _ = t_of_sexp

    let sexp_of_t =
      (function
       | Void -> Sexplib0.Sexp.Atom "Void"
       | Value -> Sexplib0.Sexp.Atom "Value"
       | Untagged_immediate -> Sexplib0.Sexp.Atom "Untagged_immediate"
       | Float64 -> Sexplib0.Sexp.Atom "Float64"
       | Float32 -> Sexplib0.Sexp.Atom "Float32"
       | Word -> Sexplib0.Sexp.Atom "Word"
       | Bits8 -> Sexplib0.Sexp.Atom "Bits8"
       | Bits16 -> Sexplib0.Sexp.Atom "Bits16"
       | Bits32 -> Sexplib0.Sexp.Atom "Bits32"
       | Bits64 -> Sexplib0.Sexp.Atom "Bits64"
       | Vec128 -> Sexplib0.Sexp.Atom "Vec128"
       | Vec256 -> Sexplib0.Sexp.Atom "Vec256"
       | Vec512 -> Sexplib0.Sexp.Atom "Vec512"
       : t -> Sexplib0.Sexp.t)
    ;;

    let _ = sexp_of_t

    [@@@end]
  end

  module Layout = struct
    type t =
      | Base of Base_sort.t
      | Any
  end
end

module type Modes_lib = sig
  include module type of struct
    include Definitions
  end

  module Mode : Wrapper
  module Modality : Wrapper
  module Crossing : Wrapper

  module Modal : sig
    include module type of struct
      include Modal
    end

    (** Accepts both [local] and [Local] capitalization. *)
    val of_string : string -> t

    (** Produces [local] capitalization. *)
    val to_string : t -> string
  end

  module Nonmodal : sig
    include module type of struct
      include Nonmodal
    end

    (** Accepts both [separable] and [Separable] capitalization. *)
    val of_string : string -> t

    (** Produces [separable] capitalization. *)
    val to_string : t -> string
  end

  module Jkind_mod : sig
    include module type of struct
      include Jkind_mod
    end

    val all : t list
    val t_of_sexp : Sexplib0.Sexp.t -> t
    val sexp_of_t : t -> Sexplib0.Sexp.t

    (** Accepts both [separable] and [Separable] capitalization. *)
    val of_string : string -> t

    (** Produces [separable] capitalization. *)
    val to_string : t -> string
  end

  module Layout : sig
    include module type of struct
      include Layout
    end

    val compare : t -> t -> int
    val t_of_sexp : Sexplib0.Sexp.t -> t
    val sexp_of_t : t -> Sexplib0.Sexp.t

    (** Accepts both [value] and [Value] capitalization. *)
    val of_string : string -> t

    (** Produces [value] capitalization. *)
    val to_string : t -> string
  end

  module type Axis =
    Axis
    with type 'a mode := 'a Mode.t
     and type 'a modality := 'a Modality.t
     and type 'a crossing := 'a Crossing.t

  module Axis : sig
    type 'a t = 'a axis
    type packed = P : 'a t -> packed [@@unboxed]

    val all : packed list
    val module_ : 'a t -> (module Axis with type t = 'a)
  end

  module Nonmodal_axis : sig
    type 'a t = 'a nonmodal_axis
    type packed = P : 'a t -> packed [@@unboxed]

    val all : packed list
    val module_ : 'a t -> (module Nonmodal_axis with type t = 'a)
  end

  module Jkind_axis : sig
    type 'a t = 'a jkind_axis
    type packed = P : 'a t -> packed [@@unboxed]

    val all : packed list
  end

  (** Modal axes *)

  module Locality : Axis with type t = locality
  module Portability : Axis with type t = portability
  module Contention : Axis with type t = contention
  module Statefulness : Axis with type t = statefulness
  module Visibility : Axis with type t = visibility
  module Linearity : Axis with type t = linearity
  module Uniqueness : Axis with type t = uniqueness
  module Yielding : Axis with type t = yielding

  (** Nonmodal jkind axes (soon to be nontrivialities) *)

  module Externality : Nonmodal_axis with type t = externality
  module Nullability : Nonmodal_axis with type t = nullability
  module Separability : Nonmodal_axis with type t = separability

  module Optional : sig
    include Per_axis with type 'a wrapped := 'a option

    (** When omitted, axis is filled in with [None]. *)
    val of_modals : Modal.t list -> t
  end

  module Modes : sig
    include Per_axis with type 'a wrapped := 'a Mode.t
    include Lattice with type t := t

    (** When omitted, axis is filled in with default or implied mode. *)
    val of_modals : Modal.t list -> t

    val to_modals : t -> Modal.t list
    val to_modals_explicit : t -> Modal.t list
  end

  module Modalities : sig
    include Per_axis with type 'a wrapped := 'a Modality.t
    include Lattice with type t := t

    (** When omitted, axis is filled in with default or implied modality, taking into
        account whether the default is for immutable or mutable values. *)
    val of_modals : mutable_implied:bool -> Modal.t list -> t

    val to_modals : mutable_implied:bool -> t -> Modal.t list
    val to_modals_explicit : t -> Modal.t list
  end

  module Crossings : sig
    include Per_axis with type 'a wrapped := 'a Crossing.t
    include Lattice with type t := t

    (** When omitted, axis is filled in with default or implied crossing. *)
    val of_modals : Modal.t list -> t

    val to_modals : t -> Modal.t list
    val to_modals_explicit : t -> Modal.t list
  end

  module Nonmodals : sig
    include module type of struct
      include Nonmodals
    end

    include Lattice with type t := t

    (** When omitted, axis is filled in with default value on that jkind axis. *)
    val of_nonmodals : Nonmodal.t list -> t

    val to_nonmodals : t -> Nonmodal.t list
    val to_nonmodals_explicit : t -> Nonmodal.t list

    type make_f = { f : 'a. 'a nonmodal_axis -> 'a }

    val make : make_f -> t
    val get : t -> 'a nonmodal_axis -> 'a
    val set : t -> 'a nonmodal_axis -> 'a -> t
  end

  module Jkind_modifiers : sig
    type 'a wrapper =
      | Modal : 'a Crossing.t * 'a Axis.t -> 'a wrapper
      | Nonmodal : 'a * 'a Nonmodal_axis.t -> 'a wrapper

    type t =
      { modals : Crossings.t
      ; nonmodals : Nonmodals.t
      }

    type make_f = { f : 'a. 'a jkind_axis -> 'a wrapper }

    (** When omitted, axis is filled in with default value for that modifier. *)
    val of_jkind_mods : Jkind_mod.t list -> t

    val to_jkind_mods : t -> Jkind_mod.t list
    val to_jkind_mods_explicit : t -> Jkind_mod.t list
    val make : make_f -> t
    val get : t -> 'a jkind_axis -> 'a

    (*_ Since [wrapper] includes a witness of the axis, we do not need to require the axis
        separately. *)
    val set : t -> 'a wrapper -> t
  end

  module Kind : sig
    type t =
      { layout : Layout.t
      ; bounds : Jkind_modifiers.t
      }

    (** Interprets [ident] as a kind, expanding abbreviations known to the compiler (e.g.
        [mutable_data]).

        Raises if [ident] does not correspond to a know layout or kind abbreviation. *)
    val of_ident_exn : ident:string -> t

    (** Applies the given modifiers [mods] to the kind [k] --- produces the kind
        [(k) mod (mods)]. This can only strengthen the kind, and so will not necessarily
        set the bounds to be exactly the modifiers provided. *)
    val apply_mods : t -> Jkind_modifiers.t -> t

    val is_subkind : t -> of_:t -> bool

    (**/**)

    (*_ Exposed for testing *)
    module Private : sig
      val interpreted_abbreviations : string list
    end
  end

  val apply_modalities : Modalities.t -> Modes.t -> Modes.t

  (** [cross crossing mode] strengthens [mode] as it would on a variable of kind
      [_ mod crossing].

      In the compiler, this is known as [cross_left]. *)
  val cross : Crossings.t -> Modes.t -> Modes.t

  (** [uncross crossing mode] is the weakest mode [mode'] such that [cross crossing mode']
      is at least as strong as [mode]. It acts as a sort of inverse to [cross].

      In the compiler, this is known as [cross_right]. *)
  val uncross : Crossings.t -> Modes.t -> Modes.t
end