Source

mutated_ocaml / testsuite / tests / typing-gadts / dynamic_frisch.ml

Diff from to

testsuite/tests/typing-gadts/dynamic_frisch.ml

   | VString of string
   | VList of variant list
   | VPair of variant * variant
- 
+
 let rec variantize: type t. t ty -> t -> variant =
   fun ty x ->
     (* type t is abstract here *)
     | Pair (ty1, ty2) ->
         VPair (variantize ty1 (fst x), variantize ty2 (snd x))
         (* t = ('a, 'b) for some 'a and 'b *)
- 
+
 exception VariantMismatch
- 
+
 let rec devariantize: type t. t ty -> variant -> t =
   fun ty v ->
     match ty, v with
   | 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;
           (List.map (fun (Field{field_type; label; get}) ->
                        (label, variantize field_type (get x))) fields)
 ;;
- 
+
 (* Extraction *)
 
 type 'a 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;
      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;
    get: ('a -> 'b);
    set: ('builder -> 'b -> unit);
   }
- 
+
 let rec devariantize: type t. t ty -> variant -> t =
   fun ty v ->
     match ty, v with
      a: int;
      b: string list;
     }
- 
+
 let my_record =
   let fields =
     [