ocaml/testsuite/tests/typing-gadts/dynamic_frisch.ml.principal...

177 lines
7.3 KiB
Plaintext
Raw Normal View History

# 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 : 't ty -> 't -> variant = <fun>
exception VariantMismatch
val devariantize : 't ty -> variant -> 't = <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 : 't ty -> 't -> 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 : 't ty -> variant -> 't = <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 (_, _) 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 (_, _) ty_sel =
Thd : ('a -> 'b, 'a) ty_sel
| Ttl : ('b -> 'c, 'd) ty_sel -> ('a -> 'b -> 'c, 'd) ty_sel
and (_, _) ty_case =
TCarg : ('b, 'a) ty_sel * ('a, 'e) ty -> ('e, 'b) ty_case
| TCnoarg : ('b, noarg) ty_sel -> ('e, 'b) ty_case
# type _ ty_env =
Enil : unit ty_env
| Econs : ('a, 'e) ty * 'e ty_env -> ('a -> 'e) ty_env
# type (_, _) eq = Eq : ('a, 'a) eq
val eq_sel : ('a, 'b) ty_sel -> ('a, 'c) ty_sel -> ('b, 'c) eq option = <fun>
val get_case :
('b, 'a) ty_sel ->
(string * ('e, 'b) ty_case) list -> string * ('a, 'e) 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 : 'e ty_env -> ('a, 'e) ty -> 'a -> variant = <fun>
# val devariantize : 'e ty_env -> ('t, 'e) ty -> variant -> 't = <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, 'e) ty -> ('a vlist, 'e) ty = <fun>
val v : variant =
VSum ("Cons",
Some
(VPair (VInt 1, VSum ("Cons", Some (VPair (VInt 2, VSum ("Nil", None)))))))
# type (_, _) 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
a#5 = ex#34 * ex#35
# type (_, _) 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 (_, _) ty_sel =
Thd : ('a -> 'b, 'a) ty_sel
| Ttl : ('b -> 'c, 'd) ty_sel -> ('a -> 'b -> 'c, 'd) ty_sel
and (_, _) 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, 'e) ty -> ('a vlist, 'e) ty = <fun>
# * * * * * * * * *