text stringlengths 0 601k |
|---|
let getPropsNameValue _acc ( loc , exp ) = match ( loc , exp ) with | { txt = Lident " props " } , { pexp_desc = Pexp_ident { txt = Lident str } } -> { propsName = str } | { txt } , _ -> raise ( Invalid_argument ( " react . component only accepts props as an option , given : " ^ Longident . last txt ) ) [ @@ raises Inv... |
let getPropsAttr payload = let defaultProps = { propsName = " Props " } in match payload with | Some ( PStr ( { pstr_desc = Pstr_eval ( { pexp_desc = Pexp_record ( recordFields , None ) } , _ ) } :: _rest ) ) -> List . fold_left getPropsNameValue defaultProps recordFields | Some ( PStr ( { pstr_desc = Pstr_eval ( { pex... |
let pluckLabelDefaultLocType ( label , default , _ , _ , loc , type_ ) = ( label , default , loc , type_ ) |
let filenameFromLoc ( pstr_loc : Location . t ) = let fileName = match pstr_loc . loc_start . pos_fname with " " -> ! Location . input_name | fileName -> fileName in let fileName = try Filename . chop_extension ( Filename . basename fileName ) with Invalid_argument _ -> fileName in let fileName = String . capitalize_as... |
let makeModuleName fileName nestedModules fnName = let fullModuleName = match ( fileName , nestedModules , fnName ) with | " " , nestedModules , " make " -> nestedModules | " " , nestedModules , fnName -> List . rev ( fnName :: nestedModules ) | fileName , nestedModules , " make " -> fileName :: List . rev nestedModule... |
let rec recursivelyMakeNamedArgsForExternal list args = match list with | ( label , default , loc , interiorType ) :: tl -> recursivelyMakeNamedArgsForExternal tl ( Typ . arrow ~ loc label ( match ( label , interiorType , default ) with | label , None , Some _ -> { ptyp_desc = Ptyp_var ( safeTypeFromValue label ) ; pty... |
let makePropsValue fnName loc namedArgListWithKeyAndRef propsType = let propsName = fnName ^ " Props " in { pval_name = { txt = propsName ; loc } ; pval_type = recursivelyMakeNamedArgsForExternal namedArgListWithKeyAndRef ( Typ . arrow nolabel { ptyp_desc = Ptyp_constr ( { txt = Lident " unit " ; loc } , [ ] ) ; ptyp_l... |
let makePropsExternal fnName loc namedArgListWithKeyAndRef propsType = { pstr_loc = loc ; pstr_desc = Pstr_primitive ( makePropsValue fnName loc namedArgListWithKeyAndRef propsType ) } [ @@ raises Invalid_argument ] |
let makePropsExternalSig fnName loc namedArgListWithKeyAndRef propsType = { psig_loc = loc ; psig_desc = Psig_value ( makePropsValue fnName loc namedArgListWithKeyAndRef propsType ) } [ @@ raises Invalid_argument ] |
let makePropsName ~ loc name = { ppat_desc = Ppat_var { txt = name ; loc } ; ppat_loc = loc ; ppat_loc_stack = [ ] ; ppat_attributes = [ ] } |
let makeObjectField loc ( str , attrs , type_ ) = { pof_desc = Otag ( { loc ; txt = str } , type_ ) ; pof_loc = loc ; pof_attributes = attrs ; } |
let makePropsType ~ loc namedTypeList = Typ . mk ~ loc ( Ptyp_constr ( { txt = Ldot ( Lident " Js " , " t " ) ; loc } , [ { ptyp_desc = Ptyp_object ( List . map ( makeObjectField loc ) namedTypeList , Closed ) ; ptyp_loc = loc ; ptyp_loc_stack = [ ] ; ptyp_attributes = [ ] ; } ; ] ) ) |
let makeExternalDecl fnName loc namedArgListWithKeyAndRef namedTypeList = makePropsExternal fnName loc ( List . map pluckLabelDefaultLocType namedArgListWithKeyAndRef ) ( makePropsType ~ loc namedTypeList ) [ @@ raises Invalid_argument ] |
let jsxMapper ( ) = let jsxVersion = ref None in let transformUppercaseCall3 ~ caller modulePath mapper loc attrs _ callArguments = let children , argsWithLabels = extractChildren ~ loc ~ removeLastPositionUnit : true callArguments in let argsForMake = argsWithLabels in let childrenExpr = transformChildrenIfListUpper ~... |
let rewrite_implementation code : Parsetree . structure = let mapper = jsxMapper ( ) in let str = mapper . structure mapper code in str [ @@ raises Invalid_argument , Failure ] |
let rewrite_signature code : Parsetree . signature = let mapper = jsxMapper ( ) in let sig_ = mapper . signature mapper code in sig_ [ @@ raises Invalid_argument , Failure ] |
let op_of_text = function " " + | " . " + -> Add |
let compop_of_text = function " " < -> LT |
let boolop_of_text = function " " && -> AND |
let source = ref 0 |
let rec remove_links type_expr = match type_expr . desc with Tlink x -> remove_links x | Tvar _ | Tnil | Tvariant _ | Tunivar _ -> type_expr | x -> { type_expr with desc = begin match x with Tarrow ( arg_label , a , b , commutable ) -> Tarrow ( arg_label , remove_links a , remove_links b , commutable ) | Ttuple ts -> T... |
let rec debug_type type_expr = { type_expr with desc = begin match type_expr . desc with Tvar None -> Tvar ( Some ( source := ! source + 1 ; " DEBUG - TVARNONE " ^ string_of_int ! source ) ) | Tarrow ( label , a , b , commutable ) -> Tarrow ( label , debug_type a , debug_type b , commutable ) | Ttuple ts -> Ttuple ( Li... |
let rec to_ocaml_heap_value expr = match expr . e with Value x -> x | ArrayExpr arr -> let x = Obj . new_block 0 ( Array . length arr ) in for i = 0 to Array . length arr - 1 do Obj . set_field x i ( to_ocaml_heap_value arr . ( i ) ) done ; x | Cons ( { e = Value h } , t ) -> let cell = Obj . new_block 0 2 in Obj . set... |
let rec finaltype_of_expression_desc typ env = function Texp_constant ( Const_int x ) -> Value ( Obj . repr x ) let cases ' = List . map ( finaltype_of_case env ) cases in Function ( cases ' , env ) let cons_chain = Cons ( finaltype_of_expression env h , finaltype_of_expression env t ) in if should_be_value_funfalse_t ... |
let finaltype_of_typedtree { str_items } = match str_items with [ { str_desc = Tstr_eval ( e , _ ) } ] -> finaltype_of_expression [ ] e | _ -> { e = Struct ( List . map ( fun x -> match x . str_desc with Tstr_value ( recflag , [ vb ] ) -> let name = match vb . vb_pat . pat_desc with Tpat_var ( i , _ ) -> Ident . name i... |
let env = Compmisc . init_path false ; Compmisc . initial_env ( ) |
let typedtree_of_string ( ? filename " " ) = code = let ast = let lexer = Lexing . from_string code in Location . init lexer filename ; Parse . implementation lexer in try let typedtree , _ = Typemod . type_implementation " foo . ml " " " " example " env ast in typedtree with e -> Location . report_exception Format . s... |
let read x = finaltype_of_typedtree ( typedtree_of_string x ) |
| [ ] -> [ ] | x :: xs -> f x :: map f xs ; ; [ %% expect { | ( letrec ( map ( function f param tail_mod_cons ( if param ( let ( block = ( makemutable 0 ( apply f ( field_imm 0 param ) ) 24029 ) ) ( seq ( apply map_dps block 1 f ( field_imm 1 param ) ) block ) ) 0 ) ) map_dps ( function dst offset [ int ] f param tail_... |
type ' a cell = { hd : ' a ; tl : ' a rec_list } [ %% expect { | 0 |
type ' a cell = { hd : ' a ; tl : ' a rec_list ; } } ] | | None -> None | Some { hd ; tl } -> Some { hd = f hd ; tl = rec_map f tl } ; ; [ %% expect { | ( letrec ( rec_map ( function f param tail_mod_cons ( if param ( let ) 24029 ) ) ( seq ( apply rec_map_dps block 1 f ( field_imm 1 * match ) ) * block ) ) ) ) 0 ) ) re... |
type ' a stream = { hd : ' a ; tl : unit -> ' a stream } if n = 0 then [ ] else f None :: ( let v = f ( Some xs . hd ) in v :: smap_stutter f ( xs . tl ( ) ) ( n - 1 ) ) ; ; [ %% expect { | 0 |
type ' a stream = { hd : ' a ; tl : unit -> ' a stream ; } ( letrec ( smap_stutter ( function f xs n [ int ] tail_mod_cons ( if ( == n 0 ) 0 ( makeblock 0 ( apply f 0 ) ( let ( v = ( apply f ( makeblock 0 ( field_imm 0 xs ) ) ) block = ( makemutable 0 v 24029 ) ) ( seq ( apply smap_stutter_dps block 1 f ( apply ( field... |
module Core_over_monad ( Monad : Preface_specs . MONAD ) ( Env : Preface_specs . Types . T0 ) = struct type env = Env . t type ' a monad = ' a Monad . t type ' a t = env -> ' a monad let upper m _ = m let run reader_m env = reader_m env let ask = Monad . return let local f reader x = reader ( f x ) let reader f = f end |
module Functor ( F : Preface_specs . FUNCTOR ) ( Env : Preface_specs . Types . T0 ) = type ' a t = Env . t -> ' a F . t let map f reader x = ( F . map f ) ( reader x ) end ) |
module Applicative ( A : Preface_specs . APPLICATIVE ) ( Env : Preface_specs . Types . T0 ) = type ' a t = Env . t -> ' a A . t let pure x = Fun . const ( A . pure x ) let apply reader_f reader_v x = A . apply ( reader_f x ) ( reader_v x ) end ) |
module Alternative ( A : Preface_specs . ALTERNATIVE ) ( Env : Preface_specs . Types . T0 ) = Alternative . Over_applicative ( Applicative ( A ) ( Env ) ) ( struct type ' a t = Env . t -> ' a A . t let neutral _ = A . neutral let combine reader_l reader_r r = A . combine ( reader_l r ) ( reader_r r ) end ) |
module Monad ( M : Preface_specs . MONAD ) ( Env : Preface_specs . Types . T0 ) = type ' a t = Env . t -> ' a M . t let return x = Fun . const ( M . return x ) let bind f reader r = M . bind ( fun a -> ( f a ) r ) ( reader r ) end ) |
module Monad_plus ( M : Preface_specs . MONAD_PLUS ) ( Env : Preface_specs . Types . T0 ) = Monad_plus . Over_monad ( Monad ( M ) ( Env ) ) ( struct type ' a t = Env . t -> ' a M . t let neutral _ = M . neutral let combine reader_l reader_r r = M . combine ( reader_l r ) ( reader_r r ) end ) |
module Over_monad ( M : Preface_specs . MONAD ) ( Env : Preface_specs . Types . T0 ) = struct include Core_over_monad ( M ) ( Env ) module Monad = Monad ( M ) ( Env ) include Monad end |
module Id = Unique_id . Int63 ( ) |
module Read_result = struct module Z = struct type ' a t = [ ` Ok of ' a | ` Eof ] [ @@ deriving bin_io , sexp ] let bind a ~ f = match a with | ` Ok a -> f a | ` Eof -> ` Eof ; ; let map a ~ f = match a with | ` Ok a -> ` Ok ( f a ) | ` Eof -> ` Eof ; ; let map = ` Custom map let return a = ` Ok a end include Z includ... |
module Internal = struct module State = struct type t = [ ` Not_in_use | ` In_use | ` Closed ] [ @@ deriving sexp ] end module Open_flags = Unix . Open_flags type open_flags = [ ` Already_closed | ` Ok of Open_flags . t | ` Error of exn ] [ @@ deriving sexp_of ] type t = { fd : Fd . t ; id : Id . t ; mutable buf : Bigs... |
type nonrec t = t [ @@ deriving sexp_of ] |
type nonrec ' a handle_chunk_result = ' a handle_chunk_result [ @@ deriving sexp_of ] |
type nonrec ' a handle_iobuf_result = ' a handle_iobuf_result [ @@ deriving sexp_of ] |
type nonrec ' a read_one_chunk_at_a_time_result = ' a read_one_chunk_at_a_time_result |
type nonrec ' a read = ' a read |
let use t = let error reason = raise_s [ % message " can not read from reader " ( reason : string ) ~ reader ( : t : t ) ] in match t . state with | ` Closed -> error " closed " | ` In_use -> error " in use " | ` Not_in_use -> t . state <- ` In_use ; ; |
let finished_read t = match t . state with | ` Closed -> ( ) | ` Not_in_use -> assert false | ` In_use -> t . state <- ` Not_in_use ; ; |
let do_read_now t f = use t ; let x = f ( ) in finished_read t ; x ; ; |
let bytes_available t = do_read_now t ( fun ( ) -> t . available ) |
let peek_available t ~ len = do_read_now t ( fun ( ) -> peek_available t ~ len ) |
let read_available t ? pos ? len s = do_read_now t ( fun ( ) -> read_available t ? pos ? len s ) |
let do_read t f = use t ; let % map x = f ( ) in finished_read t ; x ; ; |
let peek t ~ len = if len < 0 then raise_s [ % message " [ Reader . peek ] got negative len " ( len : int ) ] ; do_read t ( fun ( ) -> peek t ~ len ) ; ; |
let read t ? pos ? len s = do_read t ( fun ( ) -> read t ? pos ? len s ) |
let read_char t = do_read t ( fun ( ) -> read_char t ) |
let read_substring t s = do_read t ( fun ( ) -> read_substring t s ) |
let read_bigsubstring t s = do_read t ( fun ( ) -> read_bigsubstring t s ) |
let read_one_chunk_at_a_time t ~ handle_chunk = do_read t ( fun ( ) -> read_one_chunk_at_a_time t ~ handle_chunk ) ; ; |
let read_one_iobuf_at_a_time t ~ handle_chunk = do_read t ( fun ( ) -> read_one_iobuf_at_a_time t ~ handle_chunk ) ; ; |
let really_read t ? pos ? len s = do_read t ( fun ( ) -> really_read t ? pos ? len s ) |
let really_read_substring t s = do_read t ( fun ( ) -> really_read_substring t s ) |
let really_read_bigsubstring t s = do_read t ( fun ( ) -> really_read_bigsubstring t s ) |
let read_line t = do_read t ( fun ( ) -> read_line t ) |
let really_read_line ~ wait_time t = do_read t ( fun ( ) -> really_read_line ~ wait_time t ) |
let do_read_k ( type r r ' ) t ( read_k : ( r Or_error . t -> unit ) -> unit ) ( make_result : r -> r ' ) : r ' Deferred . t = use t ; Deferred . create ( fun result -> read_k ( fun r -> finished_read t ; Ivar . fill result ( make_result ( ok_exn r ) ) ) ) ; ; |
let read_until t p ~ keep_delim = do_read_k t ( read_until t p ~ keep_delim ) Fn . id |
let read_until_max t p ~ keep_delim ~ max = do_read_k t ( read_until_gen t p ~ keep_delim ~ max ( : Some max ) ) Fn . id ; ; |
let read_sexp ? parse_pos t = do_read_k t ( gen_read_sexp t ~ sexp_kind : Plain ? parse_pos ) ( function | ` Eof -> ` Eof | ` Ok ( sexp , _ ) -> ` Ok sexp ) ; ; |
let read_sexps ? parse_pos t = use t ; read_sexps ? parse_pos t ; ; |
let read_annotated_sexps ? parse_pos t = use t ; read_annotated_sexps ? parse_pos t ; ; |
let peek_or_read_bin_prot ? max_len t reader ~ peek_or_read = do_read_k t ( peek_or_read_bin_prot ? max_len t reader ~ peek_or_read ) Fn . id ; ; |
let peek_bin_prot ? max_len t reader = peek_or_read_bin_prot ? max_len t reader ~ peek_or_read : Peek ; ; |
let read_bin_prot ? max_len t reader = peek_or_read_bin_prot ? max_len t reader ~ peek_or_read : Read ; ; |
let read_marshal_raw t = do_read t ( fun ( ) -> read_marshal_raw t ) |
let read_marshal t = do_read t ( fun ( ) -> read_marshal t ) |
let recv t = do_read t ( fun ( ) -> recv t ) |
let read_all t read_one = read_all t read_one |
let lines t = use t ; lines t ; ; |
let contents t = do_read t ( fun ( ) -> contents t ) |
let file_contents file = with_file file ~ f : contents |
let file_lines file = let % bind t = open_file file in Pipe . to_list ( lines t ) ; ; |
let transfer t = use t ; transfer t ; ; |
let lseek t offset ~ mode = do_read t ( fun ( ) -> t . pos <- 0 ; t . available <- 0 ; Unix_syscalls . lseek t . fd offset ~ mode ) ; ; |
let ltell t = do_read t ( fun ( ) -> let % map fd_offset = Unix_syscalls . lseek t . fd Int64 . zero ~ mode ` : Cur in Int64 . ( - ) fd_offset ( Int64 . of_int t . available ) ) ; ; |
let get_error ( type a sexp ) ~ file ( ~ sexp_kind : sexp sexp_kind ) ( ~ a_of_sexp : sexp -> a ) ( annotated_sexp : Sexp . Annotated . t ) = try ignore ( a_of_sexp ( match sexp_kind with | Plain -> ( Sexp . Annotated . get_sexp annotated_sexp : sexp ) | Annotated -> ( annotated_sexp : sexp ) ) : a ) ; Ok ( ) with | ex... |
let gen_load_exn ( type sexp a ) ? exclusive ( ~ sexp_kind : sexp sexp_kind ) ~ file ( convert : sexp list -> a ) ( get_error : Sexp . Annotated . t list -> Error . t ) : a Deferred . t = let may_load_file_multiple_times = ref false in let load ~ sexp_kind = match % map Monitor . try_with ~ extract_exn : true ( fun ( )... |
type ( ' sexp , ' a , ' b ) load = ? exclusive : bool -> string -> ( ' sexp -> ' a ) -> ' b Deferred . t |
let get_load_result_exn = function | ` Result x -> x | ` Error ( exn , _sexp ) -> raise exn ; ; |
let gen_load_sexp_exn ( type a sexp ) ? exclusive ( ~ sexp_kind : sexp sexp_kind ) ~ file ( ~ a_of_sexp : sexp -> a ) = let multiple sexps = Error . create " Reader . load_sexp requires one sexp but got " ( List . length sexps , file ) [ % sexp_of : int * string ] in gen_load_exn ? exclusive ~ file ~ sexp_kind ( fun se... |
let load_sexp_exn ? exclusive file a_of_sexp = gen_load_sexp_exn ? exclusive ~ sexp_kind : Plain ~ file ~ a_of_sexp ; ; |
let load_annotated_sexp_exn ? exclusive file a_of_sexp = gen_load_sexp_exn ? exclusive ~ sexp_kind : Annotated ~ file ~ a_of_sexp ; ; |
let gen_load_sexp ? exclusive ~ sexp_kind ~ file ~ a_of_sexp = Deferred . Or_error . try_with ~ extract_exn : true ( fun ( ) -> gen_load_sexp_exn ? exclusive ~ sexp_kind ~ file ~ a_of_sexp ) ; ; |
let load_sexp ? exclusive file a_of_sexp = gen_load_sexp ? exclusive ~ sexp_kind : Plain ~ file ~ a_of_sexp ; ; |
let load_annotated_sexp ? exclusive file a_of_sexp = gen_load_sexp ? exclusive ~ sexp_kind : Annotated ~ file ~ a_of_sexp ; ; |
let gen_load_sexps_exn ( type a sexp ) ? exclusive ( ~ sexp_kind : sexp sexp_kind ) ~ file ( ~ a_of_sexp : sexp -> a ) = gen_load_exn ? exclusive ~ file ~ sexp_kind ( fun sexps -> List . map sexps ~ f : a_of_sexp ) ( fun annot_sexps -> Error . of_list ( List . filter_map annot_sexps ~ f ( : fun annot_sexp -> match get_... |
let load_sexps_exn ? exclusive file a_of_sexp = gen_load_sexps_exn ? exclusive ~ sexp_kind : Plain ~ file ~ a_of_sexp ; ; |
let load_annotated_sexps_exn ? exclusive file a_of_sexp = gen_load_sexps_exn ? exclusive ~ sexp_kind : Annotated ~ file ~ a_of_sexp ; ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.