summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-gadts/dynamic_frisch.ml.reference
blob: 39102239a9781529dcec0235ac3c6e0d41264589 (plain)
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

#                       type 'a ty =
    Int : int ty
  | String : string ty
  | List : 'a ty -> 'a list ty
  | Pair : ('a ty * 'b ty) -> ('a * 'b) ty
#                                                                     type variant =
    VInt of int
  | VString of string
  | VList of variant list
  | VPair of variant * variant
val variantize : 'a ty -> 'a -> variant = <fun>
exception VariantMismatch
val devariantize : 'a ty -> variant -> 'a = <fun>
#                                                   type 'a ty =
    Int : int ty
  | String : string ty
  | List : 'a ty -> 'a list ty
  | Pair : ('a ty * 'b ty) -> ('a * 'b) ty
  | Record : 'a record -> 'a ty
and 'a record = { path : string; fields : 'a field_ list; }
and 'a field_ = Field : ('a, 'b) field -> 'a field_
and ('a, 'b) field = { label : string; field_type : 'b ty; get : 'a -> 'b; }
#                                                     type variant =
    VInt of int
  | VString of string
  | VList of variant list
  | VPair of variant * variant
  | VRecord of (string * variant) list
val variantize : 'a ty -> 'a -> variant = <fun>
#                                                                                                   type 'a ty =
    Int : int ty
  | String : string ty
  | List : 'a ty -> 'a list ty
  | Pair : ('a ty * 'b ty) -> ('a * 'b) ty
  | Record : ('a, 'builder) record -> 'a ty
and ('a, 'builder) record = {
  path : string;
  fields : ('a, 'builder) field list;
  create_builder : unit -> 'builder;
  of_builder : 'builder -> 'a;
}
and ('a, 'builder) field =
    Field : ('a, 'builder, 'b) field_ -> ('a, 'builder) field
and ('a, 'builder, 'b) field_ = {
  label : string;
  field_type : 'b ty;
  get : 'a -> 'b;
  set : 'builder -> 'b -> unit;
}
val devariantize : 'a ty -> variant -> 'a = <fun>
#                                                   type my_record = { a : int; b : string list; }
val my_record : my_record ty =
  Record
   {path = "My_module.my_record";
    fields =
     [Field {label = "a"; field_type = Int; get = <fun>; set = <fun>};
      Field {label = "b"; field_type = List String; get = <fun>; set = <fun>}];
    create_builder = <fun>; of_builder = <fun>}
#                                                                         type noarg = Noarg
type ('a, 'b) ty =
    Int : (int, 'c) ty
  | String : (string, 'd) ty
  | List : ('a, 'e) ty -> ('a list, 'e) ty
  | Option : ('a, 'e) ty -> ('a option, 'e) ty
  | Pair : (('a, 'e) ty * ('b, 'e) ty) -> ('a * 'b, 'e) ty
  | Var : ('a, 'a -> 'e) ty
  | Rec : ('a, 'a -> 'e) ty -> ('a, 'e) ty
  | Pop : ('a, 'e) ty -> ('a, 'b -> 'e) ty
  | Conv : string * ('a -> 'b) * ('b -> 'a) * ('b, 'e) ty -> ('a, 'e) ty
  | Sum : ('a, 'e, 'b) ty_sum -> ('a, 'e) ty
and ('a, 'e, 'b) ty_sum = {
  sum_proj : 'a -> string * 'e ty_dyn option;
  sum_cases : (string * ('e, 'b) ty_case) list;
  sum_inj : 'c. ('b, 'c) ty_sel * 'c -> 'a;
}
and 'e ty_dyn = Tdyn : ('a, 'e) ty * 'a -> 'e ty_dyn
and ('a, 'b) ty_sel =
    Thd : ('a -> 'b, 'a) ty_sel
  | Ttl : ('b -> 'c, 'd) ty_sel -> ('a -> 'b -> 'c, 'd) ty_sel
and ('a, 'b) ty_case =
    TCarg : ('b, 'a) ty_sel * ('a, 'e) ty -> ('e, 'b) ty_case
  | TCnoarg : ('b, noarg) ty_sel -> ('e, 'b) ty_case
#         type 'a ty_env =
    Enil : unit ty_env
  | Econs : ('a, 'e) ty * 'e ty_env -> ('a -> 'e) ty_env
#                                                         type ('a, 'b) eq = Eq : ('a, 'a) eq
val eq_sel : ('a, 'b) ty_sel -> ('a, 'c) ty_sel -> ('b, 'c) eq option = <fun>
val get_case :
  ('a, 'b) ty_sel ->
  (string * ('c, 'a) ty_case) list -> string * ('b, 'c) ty option = <fun>
#                                                         type variant =
    VInt of int
  | VString of string
  | VList of variant list
  | VOption of variant option
  | VPair of variant * variant
  | VConv of string * variant
  | VSum of string * variant option
val may_map : ('a -> 'b) -> 'a option -> 'b option = <fun>
val variantize : 'a ty_env -> ('b, 'a) ty -> 'b -> variant = <fun>
#                                               val devariantize : 'a ty_env -> ('b, 'a) ty -> variant -> 'b = <fun>
#     val wrap_A : ('a, 'b) ty -> ([ `A of 'a ], 'b) ty = <fun>
#   val ty : ('a, ([ `A of ('a * 'b) option ] as 'b) -> 'c) ty -> ('b, 'c) ty =
  <fun>
# val v : ([ `A of (int * 'a) option ] as 'a) -> variant = <fun>
# val x : variant =
  VConv ("`A",
   VOption
    (Some
      (VPair (VInt 1,
        VConv ("`A",
         VOption (Some (VPair (VInt 2, VConv ("`A", VOption None)))))))))
#               val triple :
  ('a, 'b) ty -> ('c, 'b) ty -> ('d, 'b) ty -> ('a * 'c * 'd, 'b) ty = <fun>
val v : variant =
  VConv ("Triple", VPair (VString "A", VPair (VInt 2, VInt 3)))
#                                       val ty_abc : ([ `A of int | `B of string | `C ], 'a) ty =
  Sum
   {sum_proj = <fun>;
    sum_cases =
     [("A", TCarg (Thd, Int)); ("B", TCarg (Ttl Thd, String));
      ("C", TCnoarg (Ttl (Ttl Thd)))];
    sum_inj = <fun>}
#                                             val a : [ `A of int | `B of string | `C ] = `A 3
type 'a vlist = [ `Cons of 'a * 'a vlist | `Nil ]
val ty_list : ('a, 'b) ty -> ('a vlist, 'b) ty = <fun>
val v : variant =
  VSum ("Cons",
   Some
    (VPair (VInt 1, VSum ("Cons", Some (VPair (VInt 2, VSum ("Nil", None)))))))
#                                                               type ('a, 'b) ty =
    Int : (int, 'c) ty
  | String : (string, 'd) ty
  | List : ('a, 'e) ty -> ('a list, 'e) ty
  | Option : ('a, 'e) ty -> ('a option, 'e) ty
  | Pair : (('a, 'e) ty * ('b, 'e) ty) -> ('a * 'b, 'e) ty
  | Var : ('a, 'a -> 'e) ty
  | Rec : ('a, 'a -> 'e) ty -> ('a, 'e) ty
  | Pop : ('a, 'e) ty -> ('a, 'b -> 'e) ty
  | Conv : string * ('a -> 'b) * ('b -> 'a) * ('b, 'e) ty -> ('a, 'e) ty
  | Sum : ('a -> string * 'e ty_dyn option) *
      (string * 'e ty_dyn option -> 'a) -> ('a, 'e) ty
and 'e ty_dyn = Tdyn : ('a, 'e) ty * 'a -> 'e ty_dyn
val ty_abc : ([ `A of int | `B of string | `C ], 'e) ty = Sum (<fun>, <fun>)
#                   Characters 327-344:
      | "Cons", Some (Tdyn (Pair (_, Var), (p : a * a vlist))) -> `Cons p)))
                                           ^^^^^^^^^^^^^^^^^
Error: This pattern matches values of type a * a vlist
       but a pattern was expected which matches values of type
         ex#46 = ex#47 * ex#48
#                                                         type ('a, 'b) ty =
    Int : (int, 'd) ty
  | String : (string, 'f) ty
  | List : ('a, 'e) ty -> ('a list, 'e) ty
  | Option : ('a, 'e) ty -> ('a option, 'e) ty
  | Pair : (('a, 'e) ty * ('b, 'e) ty) -> ('a * 'b, 'e) ty
  | Var : ('a, 'a -> 'e) ty
  | Rec : ('a, 'a -> 'e) ty -> ('a, 'e) ty
  | Pop : ('a, 'e) ty -> ('a, 'b -> 'e) ty
  | Conv : string * ('a -> 'b) * ('b -> 'a) * ('b, 'e) ty -> ('a, 'e) ty
  | Sum :
      < cases : (string * ('e, 'b) ty_case) list;
        inj : 'c. ('b, 'c) ty_sel * 'c -> 'a;
        proj : 'a -> string * 'e ty_dyn option > -> ('a, 'e) ty
and 'e ty_dyn = Tdyn : ('a, 'e) ty * 'a -> 'e ty_dyn
and ('a, 'b) ty_sel =
    Thd : ('a -> 'b, 'a) ty_sel
  | Ttl : ('b -> 'c, 'd) ty_sel -> ('a -> 'b -> 'c, 'd) ty_sel
and ('a, 'b) ty_case =
    TCarg : ('b, 'a) ty_sel * ('a, 'e) ty -> ('e, 'b) ty_case
  | TCnoarg : ('b, noarg) ty_sel -> ('e, 'b) ty_case
#                                                                     val ty_abc : ([ `A of int | `B of string | `C ], 'e) ty = Sum <obj>
type 'a vlist = [ `Cons of 'a * 'a vlist | `Nil ]
val ty_list : ('a, 'b) ty -> ('a vlist, 'b) ty = <fun>
#   * * * * * * * * *