text
stringlengths
0
601k
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...
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 ] ( modu...
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_...
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 pa...
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_bod...
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 | Tex...
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...
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_mod...
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 ; ...
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 ( va...
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
let ctor_args iter = function | Tctor_tuple typs -> List . iter ~ f ( : iter . type_expr iter ) typs | Tctor_record fields -> List . iter ~ f ( : iter . field_decl iter ) fields
let ctor_decl iter { ctor_ident ; ctor_args ; ctor_ret ; ctor_loc ; ctor_ctor } = iter . location iter ctor_loc ; ident iter ctor_ident ; iter . ctor_args iter ctor_args ; Option . iter ~ f ( : iter . type_expr iter ) ctor_ret ; ignore ctor_ctor
let type_decl iter { tdec_ident ; tdec_params ; tdec_desc ; tdec_loc ; tdec_tdec } = iter . location iter tdec_loc ; ident iter tdec_ident ; List . iter ~ f ( : iter . type_expr iter ) tdec_params ; iter . type_decl_desc iter tdec_desc ; ignore tdec_tdec
let type_decl_desc iter = function | Tdec_abstract -> ( ) | Tdec_alias typ -> iter . type_expr iter typ | Tdec_record fields -> List . iter ~ f ( : iter . field_decl iter ) fields | Tdec_variant ctors -> List . iter ~ f ( : iter . ctor_decl iter ) ctors | Tdec_open -> ( ) | Tdec_extend ( name , ctors ) -> path iter nam...
let literal ( _iter : iterator ) ( _ : literal ) = ( )
let pattern iter { pat_desc ; pat_loc ; pat_type } = iter . location iter pat_loc ; iter . type0_expr iter pat_type ; iter . pattern_desc iter pat_desc
let pattern_desc iter = function | Tpat_any -> ( ) | Tpat_variable name -> ident iter name | Tpat_constraint ( pat , typ ) -> iter . type_expr iter typ ; iter . pattern iter pat | Tpat_tuple pats -> List . iter ~ f ( : iter . pattern iter ) pats | Tpat_or ( p1 , p2 ) -> iter . pattern iter p1 ; iter . pattern iter p2 |...
let expression iter { exp_desc ; exp_loc ; exp_type } = iter . location iter exp_loc ; iter . type0_expr iter exp_type ; iter . expression_desc iter exp_desc
let expression_desc iter = function | Texp_apply ( e , args ) -> iter . expression iter e ; List . iter args ~ f ( : fun ( _explicit , _label , e ) -> iter . expression iter e ) | Texp_variable name -> path iter name | Texp_literal l -> iter . literal iter l | Texp_fun ( _label , p , e , _explicit ) -> iter . pattern i...
let convert_body iter { conv_body_desc ; conv_body_loc ; conv_body_type } = iter . location iter conv_body_loc ; iter . type0_expr iter conv_body_type ; iter . convert_body_desc iter conv_body_desc
let convert_body_desc iter = function | Tconv_record fields -> List . iter fields ~ f ( : fun ( field , conv ) -> path iter field ; iter . convert_body iter conv ) | Tconv_ctor ( name , args ) -> path iter name ; List . iter args ~ f ( : fun ( _label , conv ) -> iter . convert_body iter conv ) | Tconv_tuple convs -> Li...
let convert iter { conv_desc ; conv_loc ; conv_type } = iter . location iter conv_loc ; iter . type0_expr iter conv_type ; iter . convert_desc iter conv_desc
let convert_desc iter = function | Tconv_fun ( name , body ) -> ident iter name ; iter . convert iter body | Tconv_body body -> iter . convert_body iter body
let type_conv iter = function | Ttconv_with ( _mode , decl ) -> iter . type_decl iter decl | Ttconv_to typ -> iter . type_expr iter typ
let signature iter = List . iter ~ f ( : iter . signature_item iter )
let signature_item iter { sig_desc ; sig_loc } = iter . location iter sig_loc ; iter . signature_desc iter sig_desc
let signature_desc iter = function | Tsig_value ( name , typ ) | Tsig_instance ( name , typ ) -> ident iter name ; iter . type_expr iter typ | Tsig_type decl -> iter . type_decl iter decl | Tsig_convtype ( decl , tconv , convname , typ ) -> iter . type_decl iter decl ; type_conv iter tconv ; ident iter convname ; iter ...
let module_sig iter { msig_desc ; msig_loc } = iter . location iter msig_loc ; iter . module_sig_desc iter msig_desc
let module_sig_desc iter = function | Tmty_sig sigs -> iter . signature iter sigs | Tmty_name name -> path iter name | Tmty_alias name -> path iter name | Tmty_abstract -> ( ) | Tmty_functor ( name , fsig , msig ) -> str iter name ; iter . module_sig iter fsig ; iter . module_sig iter msig
let statements iter = List . iter ~ f ( : iter . statement iter )
let statement iter { stmt_desc ; stmt_loc } = iter . location iter stmt_loc ; iter . statement_desc iter stmt_desc
let statement_desc iter = function | Tstmt_value ( p , e ) -> iter . pattern iter p ; iter . expression iter e | Tstmt_instance ( name , e ) -> ident iter name ; iter . expression iter e | Tstmt_type decl -> iter . type_decl iter decl | Tstmt_convtype ( decl , tconv , convname , conv ) -> iter . type_decl iter decl ; t...
let module_expr iter { mod_desc ; mod_loc } = iter . location iter mod_loc ; iter . module_desc iter mod_desc
let module_desc iter = function | Tmod_struct stmts -> iter . statements iter stmts | Tmod_name name -> path iter name | Tmod_functor ( name , fsig , me ) -> str iter name ; iter . module_sig iter fsig ; iter . module_expr iter me
let location ( _iter : iterator ) ( _ : Location . t ) = ( )
let longident iter = function | Longident . Lident _ -> ( ) | Ldot ( l , _ ) -> iter . longident iter l | Lapply ( l1 , l2 ) -> iter . longident iter l1 ; iter . longident iter l2
let path iter = function | Path . Pident ident -> iter . ident iter ident | Path . Pdot ( path , _ , _ ) | Path . Pocamldot ( path , _ , _ , _ ) -> iter . path iter path | Path . Papply ( path1 , path2 ) -> iter . path iter path1 ; iter . path iter path2
let ident ( _iter : iterator ) ( _ : Ident . t ) = ( )
let type0_decl ( _iter : iterator ) ( _ : Type0 . type_decl ) = ( )
let type0_expr ( _iter : iterator ) ( _ : Type0 . type_expr ) = ( )
let default_iterator = { type_expr ; type_desc ; variant ; row_tag ; field_decl ; ctor_args ; ctor_decl ; type_decl ; type_decl_desc ; literal ; pattern ; pattern_desc ; expression ; expression_desc ; convert_body ; convert_body_desc ; convert ; convert_desc ; signature_item ; signature ; signature_desc ; module_sig ; ...
type mapper = { type_expr : mapper -> type_expr -> type_expr ; type_desc : mapper -> type_desc -> type_desc ; variant : mapper -> variant -> variant ; row_tag : mapper -> row_tag -> row_tag ; field_decl : mapper -> field_decl -> field_decl ; ctor_args : mapper -> ctor_args -> ctor_args ; ctor_decl : mapper -> ctor_decl...
let with_backtrack_replace f = let snap = Type1 . Snapshot . create ( ) in let ret = f ( ) in Type1 . backtrack_replace snap ; ret
let lid mapper { Location . txt ; loc } = { Location . txt = mapper . longident mapper txt ; loc = mapper . location mapper loc }
let str mapper ( { Location . txt ; loc } : str ) = { Location . txt ; loc = mapper . location mapper loc }
let ident mapper ( { Location . txt ; loc } : Ident . t Location . loc ) = { Location . txt = mapper . ident mapper txt ; loc = mapper . location mapper loc }
let path mapper ( { Location . txt ; loc } : Path . t Location . loc ) = { Location . txt = mapper . path mapper txt ; loc = mapper . location mapper loc }
let type_expr mapper { type_desc ; type_loc ; type_type } = let type_loc = mapper . location mapper type_loc in let type_desc = mapper . type_desc mapper type_desc in let type_type = with_backtrack_replace ( fun ( ) -> mapper . type0 . type_expr mapper . type0 type_type ) in { type_desc ; type_loc ; type_type }
let type_desc mapper typ = match typ with | Ttyp_var name -> Ttyp_var ( Option . map ~ f ( : str mapper ) name ) | Ttyp_tuple typs -> Ttyp_tuple ( List . map ~ f ( : mapper . type_expr mapper ) typs ) | Ttyp_arrow ( typ1 , typ2 , explicit , label ) -> Ttyp_arrow ( mapper . type_expr mapper typ1 , mapper . type_expr map...
let variant mapper { var_ident ; var_params } = { var_ident = path mapper var_ident ; var_params = List . map ~ f ( : mapper . type_expr mapper ) var_params }
let row_tag mapper { rtag_ident ; rtag_arg ; rtag_loc } = { rtag_ident = ident mapper rtag_ident ; rtag_arg = List . map ~ f ( : mapper . type_expr mapper ) rtag_arg ; rtag_loc = mapper . location mapper rtag_loc }
let field_decl mapper { fld_ident ; fld_type ; fld_loc ; fld_fld } = { fld_loc = mapper . location mapper fld_loc ; fld_ident = ident mapper fld_ident ; fld_type = mapper . type_expr mapper fld_type ; fld_fld = with_backtrack_replace ( fun ( ) -> mapper . type0 . field_decl mapper . type0 fld_fld ) }
let ctor_args mapper = function | Tctor_tuple typs -> Tctor_tuple ( List . map ~ f ( : mapper . type_expr mapper ) typs ) | Tctor_record fields -> Tctor_record ( List . map ~ f ( : mapper . field_decl mapper ) fields )
let ctor_decl mapper { ctor_ident ; ctor_args ; ctor_ret ; ctor_loc ; ctor_ctor } = { ctor_loc = mapper . location mapper ctor_loc ; ctor_ident = ident mapper ctor_ident ; ctor_args = mapper . ctor_args mapper ctor_args ; ctor_ret = Option . map ~ f ( : mapper . type_expr mapper ) ctor_ret ; ctor_ctor = with_backtrack_...
let type_decl mapper { tdec_ident ; tdec_params ; tdec_desc ; tdec_loc ; tdec_tdec } = { tdec_loc = mapper . location mapper tdec_loc ; tdec_ident = ident mapper tdec_ident ; tdec_params = List . map ~ f ( : mapper . type_expr mapper ) tdec_params ; tdec_desc = mapper . type_decl_desc mapper tdec_desc ; tdec_tdec = wit...
let type_decl_desc mapper = function | Tdec_abstract -> Tdec_abstract | Tdec_alias typ -> Tdec_alias ( mapper . type_expr mapper typ ) | Tdec_record fields -> Tdec_record ( List . map ~ f ( : mapper . field_decl mapper ) fields ) | Tdec_variant ctors -> Tdec_variant ( List . map ~ f ( : mapper . ctor_decl mapper ) ctor...
let literal ( _iter : mapper ) ( l : literal ) = l
let pattern mapper { pat_desc ; pat_loc ; pat_type } = { pat_loc = mapper . location mapper pat_loc ; pat_desc = mapper . pattern_desc mapper pat_desc ; pat_type = with_backtrack_replace ( fun ( ) -> mapper . type0 . type_expr mapper . type0 pat_type ) }
let pattern_desc mapper = function | Tpat_any -> Tpat_any | Tpat_variable name -> Tpat_variable ( ident mapper name ) | Tpat_constraint ( pat , typ ) -> Tpat_constraint ( mapper . pattern mapper pat , mapper . type_expr mapper typ ) | Tpat_tuple pats -> Tpat_tuple ( List . map ~ f ( : mapper . pattern mapper ) pats ) |...
let convert_body mapper { conv_body_desc ; conv_body_loc ; conv_body_type } = { conv_body_loc = mapper . location mapper conv_body_loc ; conv_body_desc = mapper . convert_body_desc mapper conv_body_desc ; conv_body_type = mapper . type0 . type_expr mapper . type0 conv_body_type }
let convert_body_desc mapper = function | Tconv_record fields -> Tconv_record ( List . map fields ~ f ( : fun ( name , conv ) -> ( path mapper name , mapper . convert_body mapper conv ) ) ) | Tconv_ctor ( name , args ) -> Tconv_ctor ( path mapper name , List . map args ~ f ( : fun ( label , conv ) -> ( label , mapper ....
let convert mapper { conv_desc ; conv_loc ; conv_type } = { conv_loc = mapper . location mapper conv_loc ; conv_desc = mapper . convert_desc mapper conv_desc ; conv_type = mapper . type0 . type_expr mapper . type0 conv_type }
let convert_desc mapper = function | Tconv_fun ( name , conv ) -> Tconv_fun ( ident mapper name , mapper . convert mapper conv ) | Tconv_body conv -> Tconv_body ( mapper . convert_body mapper conv )
let expression mapper { exp_desc ; exp_loc ; exp_type } = { exp_loc = mapper . location mapper exp_loc ; exp_desc = mapper . expression_desc mapper exp_desc ; exp_type = with_backtrack_replace ( fun ( ) -> mapper . type0 . type_expr mapper . type0 exp_type ) }
let expression_desc mapper = function | Texp_apply ( e , args ) -> Texp_apply ( mapper . expression mapper e , List . map args ~ f ( : fun ( explicit , label , e ) -> ( explicit , label , mapper . expression mapper e ) ) ) | Texp_variable name -> Texp_variable ( path mapper name ) | Texp_literal l -> Texp_literal ( map...
let type_conv mapper = function | Ttconv_with ( mode , decl ) -> Ttconv_with ( mode , mapper . type_decl mapper decl ) | Ttconv_to typ -> Ttconv_to ( mapper . type_expr mapper typ )
let signature mapper = List . map ~ f ( : mapper . signature_item mapper )
let signature_item mapper { sig_desc ; sig_loc } = { sig_loc = mapper . location mapper sig_loc ; sig_desc = mapper . signature_desc mapper sig_desc }
let signature_desc mapper = function | Tsig_value ( name , typ ) -> Tsig_value ( ident mapper name , mapper . type_expr mapper typ ) | Tsig_instance ( name , typ ) -> Tsig_instance ( ident mapper name , mapper . type_expr mapper typ ) | Tsig_type decl -> Tsig_type ( mapper . type_decl mapper decl ) | Tsig_convtype ( de...
let module_sig mapper { msig_desc ; msig_loc } = { msig_loc = mapper . location mapper msig_loc ; msig_desc = mapper . module_sig_desc mapper msig_desc }
let module_sig_desc mapper = function | Tmty_sig sigs -> Tmty_sig ( mapper . signature mapper sigs ) | Tmty_name name -> Tmty_name ( path mapper name ) | Tmty_alias name -> Tmty_alias ( path mapper name ) | Tmty_abstract -> Tmty_abstract | Tmty_functor ( name , fsig , msig ) -> Tmty_functor ( str mapper name , mapper ....
let statements mapper = List . map ~ f ( : mapper . statement mapper )
let statement mapper { stmt_desc ; stmt_loc } = { stmt_loc = mapper . location mapper stmt_loc ; stmt_desc = mapper . statement_desc mapper stmt_desc }