text
stringlengths
12
786k
let report_type_expected_explanation expl ppf = let because expl_str = fprintf ppf " @ because it is in % s " expl_str in match expl with | If_conditional -> because " the condition of an if - statement " | If_no_else_branch -> because " the result of a conditional with no else branch " | While_loop_conditional -> because " the condition of a while - loop " | While_loop_body -> because " the body of a while - loop " | For_loop_start_index -> because " a for - loop start index " | For_loop_stop_index -> because " a for - loop stop index " | For_loop_body -> because " the body of a for - loop " | Assert_condition -> because " the condition of an assertion " | Sequence_left_hand_side -> because " the left - hand side of a sequence " | When_guard -> because " a when - guard "
let report_type_expected_explanation_opt expl ppf = match expl with | None -> ( ) | Some expl -> report_type_expected_explanation expl ppf
let report_unification_error ~ loc ? sub env trace ? type_expected_explanation txt1 txt2 = Location . error_of_printer ~ loc ? sub ( fun ppf ( ) -> Printtyp . report_unification_error ppf env trace ? type_expected_explanation txt1 txt2 ) ( )
let report_error ~ loc env = function | Constructor_arity_mismatch ( lid , expected , provided ) -> Location . errorf ~ loc " [ @ The constructor % a @ expects % i argument ( s ) , @ \ but is applied here to % i argument ( s ) ] " @ longident lid expected provided | Label_mismatch ( lid , trace ) -> report_unification_error ~ loc env trace ( function ppf -> fprintf ppf " The record field % a @ belongs to the type " longident lid ) ( function ppf -> fprintf ppf " but is mixed here with fields of type " ) | Pattern_type_clash ( trace , pat ) -> let diff = type_clash_of_trace trace in let sub = report_pattern_type_clash_hints pat diff in Location . error_of_printer ~ loc ~ sub ( fun ppf ( ) -> Printtyp . report_unification_error ppf env trace ( function ppf -> fprintf ppf " This pattern matches values of type " ) ( function ppf -> fprintf ppf " but a pattern was expected which matches values of \ type " ) ; ) ( ) | Or_pattern_type_clash ( id , trace ) -> report_unification_error ~ loc env trace ( function ppf -> fprintf ppf " The variable % s on the left - hand side of this \ or - pattern has type " ( Ident . name id ) ) ( function ppf -> fprintf ppf " but on the right - hand side it has type " ) | Multiply_bound_variable name -> Location . errorf ~ loc " Variable % s is bound several times in this matching " name | Orpat_vars ( id , valid_idents ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> fprintf ppf " Variable % s must occur on both sides of this | pattern " ( Ident . name id ) ; spellcheck_idents ppf id valid_idents ) ( ) | Expr_type_clash ( trace , explanation , exp ) -> let diff = type_clash_of_trace trace in let sub = report_expr_type_clash_hints exp diff in Location . error_of_printer ~ loc ~ sub ( fun ppf ( ) -> Printtyp . report_unification_error ppf env trace ~ type_expected_explanation : ( report_type_expected_explanation_opt explanation ) ( function ppf -> fprintf ppf " This expression has type " ) ( function ppf -> fprintf ppf " but an expression was expected of type " ) ; ) ( ) | Apply_non_function typ -> begin match ( repr typ ) . desc with Tarrow _ -> Location . errorf ~ loc " [ @< v [ >@< 2 > This function has type @ % a ] @\ @ [ @ It is applied to too many arguments ; @ % s ] ] " @@ type_expr typ " maybe you forgot a ` ; ' . " ; | _ -> Location . errorf ~ loc " [ @< v [ >@< 2 > This expression has type @ % a ] @@ % s ] " @ type_expr typ " This is not a function ; it cannot be applied . " end | Apply_wrong_label ( l , ty ) -> let print_label ppf = function | Nolabel -> fprintf ppf " without label " | l -> fprintf ppf " with label % s " ( prefixed_label_name l ) in Location . errorf ~ loc " [ @< v [ >@< 2 > The function applied to this argument has type @ % a ] . @@\ This argument cannot be applied % a ] " @ type_expr ty print_label l | Label_multiply_defined s -> Location . errorf ~ loc " The record field label % s is defined several times " s | Label_missing labels -> let print_labels ppf = List . iter ( fun lbl -> fprintf ppf " @ % s " ( Ident . name lbl ) ) in Location . errorf ~ loc " [ @< hov > Some record fields are undefined :% a ] " @ print_labels labels | Label_not_mutable lid -> Location . errorf ~ loc " The record field % a is not mutable " longident lid | Wrong_name ( eorp , ty_expected , kind , p , name , valid_names ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> let { ty ; explanation } = ty_expected in if Path . is_constructor_typath p then begin fprintf ppf " [ @ The field % s is not part of the record \ argument for the % a constructor ] " @ name path p ; end else begin fprintf ppf " [ [ @@< 2 >% s type @ % a % t ] @@ \ The % s % s does not belong to type % a ] " @ eorp type_expr ty ( report_type_expected_explanation_opt explanation ) ( label_of_kind kind ) name path p ; end ; spellcheck ppf name valid_names ) ( ) | Name_type_mismatch ( kind , lid , tp , tpl ) -> let name = label_of_kind kind in Location . error_of_printer ~ loc ( fun ppf ( ) -> report_ambiguous_type_error ppf env tp tpl ( function ppf -> fprintf ppf " The % s % a @ belongs to the % s type " name longident lid kind ) ( function ppf -> fprintf ppf " The % s % a @ belongs to one of the following % s types " : name longident lid kind ) ( function ppf -> fprintf ppf " but a % s was expected belonging to the % s type " name kind ) ) ( ) | Invalid_format msg -> Location . errorf ~ loc " % s " msg | Undefined_method ( ty , me , valid_methods ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> fprintf ppf " [ @< v [ >@ This expression has type ; @< 1 2 >% a ] , @@\ It has no method % s ] " @ type_expr ty me ; begin match valid_methods with | None -> ( ) | Some valid_methods -> spellcheck ppf me valid_methods end ) ( ) | Undefined_inherited_method ( me , valid_methods ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> fprintf ppf " This expression has no method % s " me ; spellcheck ppf me valid_methods ; ) ( ) | Virtual_class cl -> Location . errorf ~ loc " Cannot instantiate the virtual class % a " longident cl | Unbound_instance_variable ( var , valid_vars ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> fprintf ppf " Unbound instance variable % s " var ; spellcheck ppf var valid_vars ; ) ( ) | Instance_variable_not_mutable v -> Location . errorf ~ loc " The instance variable % s is not mutable " v | Not_subtype ( tr1 , tr2 ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> report_subtyping_error ppf env tr1 " is not a subtype of " tr2 ) ( ) | Outside_class -> Location . errorf ~ loc " This object duplication occurs outside a method definition " | Value_multiply_overridden v -> Location . errorf ~ loc " The instance variable % s is overridden several times " v | Coercion_failure ( ty , ty ' , trace , b ) -> Location . error_of_printer ~ loc ( fun ppf ( ) -> Printtyp . report_unification_error ppf env trace ( function ppf -> let ty , ty ' = prepare_expansion ( ty , ty ' ) in fprintf ppf " This expression cannot be coerced to type ; @< 1 2 >% a ; @ \ it has type " ( type_expansion ty ) ty ' ) ( function ppf -> fprintf ppf " but is here used with type " ) ; if b then fprintf ppf " . . [ @@< hov >% s @ % s @ % s ] " @ " This simple coercion was not fully general . " " Hint : Consider using a fully explicit coercion " " of the form : ` ( foo : ty1 :> ty2 ) ' . " ) ( ) | Too_many_arguments ( in_function , ty , explanation ) -> if in_function then begin Location . errorf ~ loc " This function expects too many arguments , @ \ it should have type @ % a % t " type_expr ty ( report_type_expected_explanation_opt explanation ) end else begin Location . errorf ~ loc " This expression should not be a function , @ \ the expected type is @ % a % t " type_expr ty ( report_type_expected_explanation_opt explanation ) end | Abstract_wrong_label ( l , ty , explanation ) -> let label_mark = function | Nolabel -> " but its first argument is not labelled " | l -> sprintf " but its first argument is labelled % s " ( prefixed_label_name l ) in Location . errorf ~ loc " [ @< v [ >@< 2 > This function should have type @ % a % t ] , @@% s ] " @ type_expr ty ( report_type_expected_explanation_opt explanation ) ( label_mark l ) | Scoping_let_module ( id , ty ) -> Location . errorf ~ loc " This ` let module ' expression has type @ % a @ \ In this type , the locally bound module name % s escapes its scope " type_expr ty id | Private_type ty -> Location . errorf ~ loc " Cannot create values of the private type % a " type_expr ty | Private_label ( lid , ty ) -> Location . errorf ~ loc " Cannot assign field % a of the private type % a " longident lid type_expr ty | Private_constructor ( constr , ty ) -> Location . errorf ~ loc " Cannot use private constructor % s to create values of type % a " constr . cstr_name type_expr ty | Not_a_variant_type lid -> Location . errorf ~ loc " The type % a @ is not a variant type " longident lid | Incoherent_label_order -> Location . errorf ~ loc " This function is applied to arguments @ \ in an order different from other calls . @ \ This is only allowed when the real type is known . " | Less_general ( kind , trace ) -> report_unification_error ~ loc env trace ( fun ppf -> fprintf ppf " This % s has type " kind ) ( fun ppf -> fprintf ppf " which is less general than " ) | Modules_not_allowed -> Location . errorf ~ loc " Modules are not allowed in this pattern . " | Cannot_infer_signature -> Location . errorf ~ loc " The signature for this packaged module couldn ' t be inferred . " | Not_a_packed_module ty -> Location . errorf ~ loc " This expression is packed module , but the expected type is @ % a " type_expr ty | Unexpected_existential ( reason , name , types ) -> let reason_str = match reason with | In_class_args -> " Existential types are not allowed in class arguments " | In_class_def -> " Existential types are not allowed in bindings inside \ class definition " | In_self_pattern -> " Existential types are not allowed in self patterns " | At_toplevel -> " Existential types are not allowed in toplevel bindings " | In_group -> " Existential types are not allowed in " \ let . . . and . . . " \ bindings " | In_rec -> " Existential types are not allowed in recursive bindings " | With_attributes -> " Existential types are not allowed in presence of attributes " in begin match List . find ( fun ty -> ty <> " " $ ^ name ) types with | example -> Location . errorf ~ loc " % s , @ but this pattern introduces the existential type % s . " reason_str example | exception Not_found -> Location . errorf ~ loc " % s , @ but the constructor % s introduces existential types . " reason_str name end | Invalid_interval -> Location . errorf ~ loc " [ @ Only character intervals are supported in patterns . ] " @ | Invalid_for_loop_index -> Location . errorf ~ loc " [ @ Invalid for - loop index : only variables and _ are allowed . ] " @ | No_value_clauses -> Location . errorf ~ loc " None of the patterns in this ' match ' expression match values . " | Exception_pattern_disallowed -> Location . errorf ~ loc " [ @ Exception patterns are not allowed in this position . ] " @ | Mixed_value_and_exception_patterns_under_guard -> Location . errorf ~ loc " [ @ Mixing value and exception patterns under when - guards is not \ supported . ] " @ | Inlined_record_escape -> Location . errorf ~ loc " [ @ This form is not allowed as the type of the inlined record could \ escape . ] " @ | Inlined_record_expected -> Location . errorf ~ loc " [ @ This constructor expects an inlined record argument . ] " @ | Unrefuted_pattern pat -> Location . errorf ~ loc " [ @% s @ % s @ % a ] " @ " This match case could not be refuted . " " Here is an example of a value that would reach it " : Printpat . top_pretty pat | Invalid_extension_constructor_payload -> Location . errorf ~ loc " Invalid [ %% extension_constructor ] payload , a constructor is expected . " | Not_an_extension_constructor -> Location . errorf ~ loc " This constructor is not an extension constructor . " | Literal_overflow ty -> Location . errorf ~ loc " Integer literal exceeds the range of representable integers of type % s " ty | Unknown_literal ( n , m ) -> Location . errorf ~ loc " Unknown modifier ' % c ' for literal % s % c " m n m | Illegal_letrec_pat -> Location . errorf ~ loc " Only variables are allowed as left - hand side of ` let rec ' " | Illegal_letrec_expr -> Location . errorf ~ loc " This kind of expression is not allowed as right - hand side of ` let rec ' " | Illegal_class_expr -> Location . errorf ~ loc " This kind of recursive class expression is not allowed " | Letop_type_clash ( name , trace ) -> report_unification_error ~ loc env trace ( function ppf -> fprintf ppf " The operator % s has type " name ) ( function ppf -> fprintf ppf " but it was expected to have type " ) | Andop_type_clash ( name , trace ) -> report_unification_error ~ loc env trace ( function ppf -> fprintf ppf " The operator % s has type " name ) ( function ppf -> fprintf ppf " but it was expected to have type " ) | Bindings_type_clash ( trace ) -> report_unification_error ~ loc env trace ( function ppf -> fprintf ppf " These bindings have type " ) ( function ppf -> fprintf ppf " but bindings were expected of type " ) | Empty_pattern -> assert false
let report_error ~ loc env err = wrap_printing_env ~ error : true env ( fun ( ) -> report_error ~ loc env err )
let ( ) = Location . register_error_of_exn ( function | Error ( loc , env , err ) -> Some ( report_error ~ loc env err ) | Error_forward err -> Some err | _ -> None )
let ( ) = Persistent_env . add_delayed_check_forward := add_delayed_check ; Env . add_delayed_check_forward := add_delayed_check ; ( )
let type_expect ? in_function env e ty = type_expect ? in_function env e ty
let type_exp env e = type_exp env e
let type_argument env e t1 t2 = type_argument env e t1 t2
let x = function 0 . . . 1 . -> ( ) ^^^^^^^^ } ] |
let f = function None None -> 0 [ %% expect { | ^^^^^^^^^ but is applied here to 1 argument ( s ) } ] |
let x = None None [ %% expect { | ^^^^^^^^^ but is applied here to 1 argument ( s ) } ] |
type t = A of { x : int }
let f = function ( A ( x : _ ) ) -> 0 [ %% expect { |
type t = A of { x : int ; } ^^^^^ } ] |
let f = function Some ( exception Not_found ) -> 0 [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^ } ] |
let f = function [ % ext ] -> 0 [ %% expect { | ^^^ } ] |
let rec f x = ( ( ) , ( ) : _ -> _ -> _ ) [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^ but an expression was expected of type ' c -> ' d -> ' e } ] |
let rec g x = ( ( ( ) , ( ) ) : _ -> _ :> _ ) [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ but an expression was expected of type ' c -> ' d } ] |
let f x = match x with exception Not_found -> ( ) ; ; [ %% expect { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } ] |
type r = { x : int }
let r = { x = 1 ; x = 1 } [ %% expect { |
type r = { x : int ; } ^^^^^^^^^^^^^ } ] |
let ( ) = { x = 1 } . x <- 2 [ %% expect { | ^^^^^^^^^^^^^^^^ } ] |
let ( ) = for Some i = 3 to 4 do ( ) done ; [ %% expect { | ^^^^^^ } ] | inherit v as super method m = 0 method x : int = super # m end ; ; [ %% expect { | ^^^^^ } ] |
let x = new v [ %% expect { | ^^^^^ } ] |
let x = object val x = 1 method m = x <- 0 end [ %% expect { | ^^^^ } ] |
let x = object ( self ) method m = self <- 0 end [ %% expect { | ^^^^^^^^ } ] | [ %% expect { | ^^^^^^^^^^^^^^ } ] |
let f x = { < y = x } > [ %% expect { | ^^^^^^^^^^^ } ] | [ %% expect { | ^^^^^^^^^ } ] |
module type empty = sig end
let f ( x : int ) = ( )
let x = f ( module struct end )
module type empty = sig end ^^^^^^^^^^^^^^^^^^^ } ] |
let x = [ % extension_constructor A ]
type t = A ^ } ] |
let x = [ % extension_constructor ] ^^^^^^^^^^^^^^^^^^^^^^^^ } ] |
let x = format_of_string " % z " ^^^^ } ] |
let f ~ x = x + 2
let y = f ~ y : 1 ^ } ] |
let g f = f ~ x : 0 ~ y : 0 ; f ~ y : 0 ~ x : 0 ^ in an order different from other calls . This is only allowed when the real type is known . } ] |
type t = A of { x : int }
let x = A 1
type t = A of { x : int ; } ^^^ } ] |
type ' a t = A of ' a
let rec A x = A ( A ( ) )
type ' a t = A of ' a ^^^ } ] |
let quadratic ( x , x ) = x * x ^ } ] |
type t = A of int | B of float | C
let f ( A x | B x ) = 0
type t = A of int | B of float | C ^^^^^^^^^ int but on the right - hand side it has type float } ] |
let f ( A x | C ) = 0 ^^^^^^^ } ] |
let f ( A x | B y ) = 0 ^^^^^^^^^ } ] |
let f = function # t -> ( )
type t = [ ] ^ } ] |
let f { x ; x = y ; x = z } = x ^^^^^^^^^^^ } ] |
let x = ( [ ` B ] [ ` :> A ] ) ^^^^ [ > ` B ] list but is here used with type [ < ` A ] } ] |
let o = object method m = instance <- 0 end [ %% expect { | ^^^^^^^^^^^^^ } ] |
let x = function | ` azdwbie -> ( ) | ` c7diagq -> ( ) [ %% expect { | ^^^^^^^^ Change one of them . } ] |
let x = ` azdwbie = ` c7diagq [ %% expect { | ^^^^^^^^ Change one of them . } ] |
type ' a x = | X : [ ` > azdwbie ] x | Y : [ ` > c7diagq ] x
let x = function | X -> ( ) | Y -> ( ) [ %% expect { |
type ' a x = X : [ > ` azdwbie ] x | Y : [ > ` c7diagq ] x ^ Change one of them . } ] |
let f = function { x ; y } -> x
type t = { x : unit ; }
type s = { y : unit ; } ^ but is mixed here with fields of type t } ] |
let x = [ % ocaml . error " Expression error " ] ^^^^^^^^^^^ } ] |
let f [ % ocaml . error " Pattern error " ] = ( ) ^^^^^^^^^^^ } ] |
let check f = f ( )
let f ~ x = ( )
let ( ) = check f ; ; } ] |
let ( ) = f ~ y : 1 ^ } ] |
let f ? x ~ a ? y ~ z = ( )
let g = f ? y : None ? x : None ~ a ( ) : ^^^^ ? x ' : a -> a ' : b -> ? y ' : c -> z ' : d -> unit } ] |
let f ( g : ? x : _ -> _ ) = g ~ y : None ? x : None ; g ? x : None ( ) [ %% expect { | ^^^^ } ] |
module Record = struct module type S = sig module Typed_field : Typed_fields_lib . S val form_for_field : ' a Typed_field . t -> ' a Form . t Computation . t end let attach_fieldname_to_error name t = Form . map_error t ~ f ( : Error . tag ~ tag ( : sprintf " in field " ^ name ) ) ; ; let make ( type a ) ( module M : S with type Typed_field . derived_on = a ) = let module Form_value = struct type ' a t = ' a Form . t Bonsai . Computation . t end in let module App = struct include Bonsai . Computation type ' a s = ' a Form . t let translate = Fn . id end in let module The_form_values = Typed_field_map . Make ( M . Typed_field ) ( Form_value ) in let module The_forms = Typed_field_map . Make ( M . Typed_field ) ( Form ) in let module The_results = Typed_field_map . Make ( M . Typed_field ) ( Or_error ) in let module To_forms = The_form_values . As_applicative . To_other_map ( App ) ( The_forms ) in let form_values_per_field = let f field = let % sub subform = M . form_for_field field in let % map . Computation subform = Form . Dynamic . error_hint subform in subform |> Form . Private . group_list |> Form . Private . suggest_label ( M . Typed_field . name field ) |> attach_fieldname_to_error ( M . Typed_field . name field ) in The_form_values . create { f } in let % map . Computation forms_per_field = To_forms . run form_values_per_field in let view = M . Typed_field . Packed . all |> List . map ~ f ( : fun { f = T field } -> Form . view ( The_forms . find forms_per_field field ) ) |> Form . View . Private . List in let value = let f field = Form . value ( The_forms . find forms_per_field field ) in The_results . As_applicative . transpose ( module Or_error ) ~ create ( : fun { f } -> M . Typed_field . create { f } ) ( The_results . create { f } ) in let set r = M . Typed_field . Packed . all |> List . map ~ f ( : fun { f = T field } -> Form . set ( The_forms . find forms_per_field field ) ( M . Typed_field . get field r ) ) |> Vdom . Effect . Many in Form . Expert . create ~ view ~ value ~ set ; ; end
module Variant = struct module type S = sig module Typed_variant : Typed_variants_lib . S val form_for_variant : ' a Typed_variant . t -> ' a Form . t Computation . t end let make ( type a ) ( module M : S with type Typed_variant . derived_on = a ) = let % sub picker = Elements . Dropdown . enumerable [ % here ] ( module struct include M . Typed_variant . Packed let equal = [ % compare . equal : t ] end ) in let picker_value = picker >>| Form . value_or_default ~ default ( : List . hd_exn M . Typed_variant . Packed . all ) in let % sub inner = Bonsai . enum ( module M . Typed_variant . Packed ) ~ match_ : picker_value ~ with_ ( : fun { f = T p } -> let % map . Computation form_for_constructor = M . form_for_variant p in let parse_exn content = M . Typed_variant . create p content in let unparse kind = match M . Typed_variant . get p kind with | None -> let expected = M . Typed_variant . Packed . pack p in let found = M . Typed_variant . which kind in raise_s [ % message " BUG " [ % here ] ( expected : M . Typed_variant . Packed . t ) ( found : M . Typed_variant . Packed . t ) ] | Some v -> v in Form . project form_for_constructor ~ parse_exn ~ unparse ) in let % sub get_inner_form = Bonsai_extra . yoink inner in let % arr inner = inner and picker = picker and get_inner_form = get_inner_form in let view = Form . View . Private . Header_group { header_view = Form . view picker ; view = Form . view inner ; label = None ; tooltip = None } in let value = Form . value inner in let set value = let constructor = M . Typed_variant . which value in let open Ui_effect . Let_syntax in let % bind ( ) = Form . set picker constructor in let % bind inner = get_inner_form in Form . set inner value in Form . Expert . create ~ view ~ value ~ set ; ; end
type ident = Ident . t Location . loc
type path = Path . t Location . loc
type type_expr = { type_desc : type_desc ; type_loc : Location . t ; type_type : Type0 . type_expr } | Ttyp_var of str option | Ttyp_tuple of type_expr list | Ttyp_arrow of type_expr * type_expr * explicitness * Asttypes . arg_label | Ttyp_ctor of variant | Ttyp_poly of type_expr list * type_expr | Ttyp_prover of type_expr | Ttyp_conv of type_expr * type_expr | Ttyp_opaque of type_expr | Ttyp_alias of type_expr * str | Ttyp_row of row_tag list * closed_flag * ident list option | Ttyp_row_subtract of type_expr * ident list { rtag_ident : ident ; rtag_arg : type_expr list ; rtag_loc : Location . t }
type field_decl = { fld_ident : ident ; fld_type : type_expr ; fld_loc : Location . t ; fld_fld : Type0 . field_decl }
type ctor_args = | Tctor_tuple of type_expr list | Tctor_record of field_decl list
type ctor_decl = { ctor_ident : ident ; ctor_args : ctor_args ; ctor_ret : type_expr option ; ctor_loc : Location . t ; ctor_ctor : Type0 . ctor_decl }
type type_decl = { tdec_ident : ident ; tdec_params : type_expr list ; tdec_desc : type_decl_desc ; tdec_loc : Location . t ; tdec_tdec : Type0 . type_decl } | Tdec_abstract | Tdec_alias of type_expr | Tdec_record of field_decl list | Tdec_variant of ctor_decl list | Tdec_open | Tdec_extend of path * ctor_decl list
type pattern = { pat_desc : pattern_desc ; pat_loc : Location . t ; pat_type : Type0 . type_expr } | Tpat_any | Tpat_variable of ident | Tpat_constraint of pattern * type_expr | Tpat_tuple of pattern list | Tpat_or of pattern * pattern | Tpat_literal of literal | Tpat_record of ( path * pattern ) list | Tpat_ctor of path * pattern option | Tpat_row_ctor of ident * pattern list
type convert_body = { conv_body_desc : convert_body_desc ; conv_body_loc : Location . t ; conv_body_type : Type0 . type_expr } | Tconv_record of ( path * convert_body ) list | Tconv_ctor of path * ( Asttypes . arg_label * convert_body ) list | Tconv_tuple of convert_body list | Tconv_arrow of convert_body * convert_body | Tconv_identity | Tconv_opaque { conv_desc : convert_desc ; conv_loc : Location . t ; conv_type : Type0 . type_expr }
type expression = { exp_desc : expression_desc ; exp_loc : Location . t ; exp_type : Type0 . type_expr } | Texp_apply of expression * ( explicitness * Asttypes . arg_label * expression ) list | Texp_variable of path | Texp_literal of literal | Texp_fun of Asttypes . arg_label * pattern * expression * explicitness | Texp_newtype of ident * expression | Texp_seq of expression * expression | Texp_let of pattern * expression * expression | Texp_instance of ident * expression * expression | Texp_constraint of expression * type_expr | Texp_tuple of expression list | Texp_match of expression * ( pattern * expression ) list | Texp_field of expression * path | Texp_record of ( path * expression ) list * expression option | Texp_ctor of path * expression option | Texp_row_ctor of ident * expression list | Texp_unifiable of { mutable expression : expression option ; name : ident ; id : int } | Texp_if of expression * expression * expression option | Texp_read of convert * ( Asttypes . arg_label * expression ) list * expression | Texp_prover of convert * ( Asttypes . arg_label * expression ) list * expression | Texp_convert of convert
type conv_type = | Ttconv_with of mode * type_decl | Ttconv_to of type_expr
type signature_item = { sig_desc : signature_desc ; sig_loc : Location . t } | Tsig_value of ident * type_expr | Tsig_instance of ident * type_expr | Tsig_type of type_decl | Tsig_convtype of type_decl * conv_type * ident * type_expr | Tsig_rectype of type_decl list | Tsig_module of ident * module_sig | Tsig_modtype of ident * module_sig | Tsig_open of path | Tsig_typeext of variant * ctor_decl list | Tsig_request of type_expr * ctor_decl | Tsig_multiple of signature | Tsig_prover of signature | Tsig_convert of ident * type_expr | Tmty_sig of signature | Tmty_name of path | Tmty_alias of path | Tmty_abstract | Tmty_functor of str * module_sig * module_sig
type statement = { stmt_desc : statement_desc ; stmt_loc : Location . t } | Tstmt_value of pattern * expression | Tstmt_instance of ident * expression | Tstmt_type of type_decl | Tstmt_convtype of type_decl * conv_type * ident * convert | Tstmt_rectype of type_decl list | Tstmt_module of ident * module_expr | Tstmt_modtype of ident * module_sig | Tstmt_open of path | Tstmt_open_instance of path | Tstmt_typeext of variant * ctor_decl list | Tstmt_request of type_expr * ctor_decl * ( pattern option * expression ) option | Tstmt_multiple of statements | Tstmt_prover of statements | Tstmt_convert of ident * type_expr * convert | Tmod_struct of statements | Tmod_name of path | Tmod_functor of str * module_sig * module_expr
type iterator = { type_expr : iterator -> type_expr -> unit ; type_desc : iterator -> type_desc -> unit ; variant : iterator -> variant -> unit ; row_tag : iterator -> row_tag -> unit ; field_decl : iterator -> field_decl -> unit ; ctor_args : iterator -> ctor_args -> unit ; ctor_decl : iterator -> ctor_decl -> unit ; type_decl : iterator -> type_decl -> unit ; type_decl_desc : iterator -> type_decl_desc -> unit ; literal : iterator -> literal -> unit ; pattern : iterator -> pattern -> unit ; pattern_desc : iterator -> pattern_desc -> unit ; expression : iterator -> expression -> unit ; expression_desc : iterator -> expression_desc -> unit ; convert_body : iterator -> convert_body -> unit ; convert_body_desc : iterator -> convert_body_desc -> unit ; convert : iterator -> convert -> unit ; convert_desc : iterator -> convert_desc -> unit ; signature_item : iterator -> signature_item -> unit ; signature : iterator -> signature -> unit ; signature_desc : iterator -> signature_desc -> unit ; module_sig : iterator -> module_sig -> unit ; module_sig_desc : iterator -> module_sig_desc -> unit ; statement : iterator -> statement -> unit ; statements : iterator -> statements -> unit ; statement_desc : iterator -> statement_desc -> unit ; module_expr : iterator -> module_expr -> unit ; module_desc : iterator -> module_desc -> unit ; location : iterator -> Location . t -> unit ; longident : iterator -> Longident . t -> unit ; ident : iterator -> Ident . t -> unit ; path : iterator -> Path . t -> unit ; type0_expr : iterator -> Type0 . type_expr -> unit ; type0_decl : iterator -> Type0 . type_decl -> unit }
let lid iter { Location . txt ; loc } = iter . longident iter txt ; iter . location iter loc
let str iter ( { Location . txt = _ ; loc } : str ) = iter . location iter loc
let ident iter ( { Location . txt ; loc } : Ident . t Location . loc ) = iter . ident iter txt ; iter . location iter loc
let path iter ( { Location . txt ; loc } : Path . t Location . loc ) = iter . location iter loc ; iter . path iter txt
let type_expr iter { type_desc ; type_loc ; type_type } = iter . location iter type_loc ; iter . type0_expr iter type_type ; iter . type_desc iter type_desc
let type_desc iter = function | Ttyp_var name -> Option . iter ~ f ( : str iter ) name | Ttyp_tuple typs -> List . iter ~ f ( : iter . type_expr iter ) typs | Ttyp_arrow ( typ1 , typ2 , _ , _ ) -> iter . type_expr iter typ1 ; iter . type_expr iter typ2 | Ttyp_ctor variant -> iter . variant iter variant | Ttyp_poly ( vars , typ ) -> List . iter ~ f ( : iter . type_expr iter ) vars ; iter . type_expr iter typ | Ttyp_prover typ -> iter . type_expr iter typ | Ttyp_conv ( typ1 , typ2 ) -> iter . type_expr iter typ1 ; iter . type_expr iter typ2 | Ttyp_opaque typ -> iter . type_expr iter typ | Ttyp_alias ( typ , name ) -> str iter name ; iter . type_expr iter typ | Ttyp_row ( tags , _closed , min_tags ) -> Option . iter ~ f ( : List . iter ~ f ( : ident iter ) ) min_tags ; List . iter ~ f ( : iter . row_tag iter ) tags | Ttyp_row_subtract ( typ , tags ) -> iter . type_expr iter typ ; List . iter ~ f ( : ident iter ) tags
let variant iter { var_ident ; var_params } = path iter var_ident ; List . iter ~ f ( : iter . type_expr iter ) var_params
let row_tag iter { rtag_ident ; rtag_arg ; rtag_loc } = ident iter rtag_ident ; iter . location iter rtag_loc ; List . iter ~ f ( : iter . type_expr iter ) rtag_arg
let field_decl iter { fld_ident ; fld_type ; fld_loc ; fld_fld } = iter . location iter fld_loc ; ident iter fld_ident ; iter . type_expr iter fld_type ; ignore fld_fld