text stringlengths 0 601k |
|---|
let env_of_pattern expected_k pat = env_of_pattern expected_k Env . empty pat |
let rec pattern h ( { p_desc = desc ; p_loc = loc } as pat ) ty = match desc with | Ewildpat -> pat . p_typ <- ty | Econstpat ( im ) -> unify_pat pat ty ( immediate im ) ; pat . p_typ <- ty | Econstr0pat ( c0 ) -> let qualid , { constr_res = ty_res ; constr_arity = n } = constr loc c0 in if n <> 0 then error loc ( Econ... |
let pattern_list h pat_list ty_list = List . iter2 ( pattern h ) pat_list ty_list |
let check_total_pattern p = let is_exhaustive = Patternsig . check_activate p . p_loc p in if not is_exhaustive then error p . p_loc Epattern_not_total |
let check_total_pattern_list p_list = List . iter check_total_pattern p_list |
let match_handlers body loc expected_k h total m_handlers pat_ty ty = let handler ( { m_pat = pat ; m_body = b } as mh ) = let h0 = env_of_pattern expected_k pat in pattern h0 pat pat_ty ; mh . m_env <- h0 ; let h = Env . append h0 h in body expected_k h b ty in let defined_names_list = List . map handler m_handlers in... |
let present_handlers scondpat body loc expected_k h p_h_list b_opt expected_ty = let handler ( { p_cond = scpat ; p_body = b } as ph ) = let h0 = env_of_scondpat expected_k scpat in let h = Env . append h0 h in let is_zero = Ztypes . is_continuous_kind expected_k in scondpat expected_k is_zero h scpat ; ph . p_zero <- ... |
let rec expression expected_k h ( { e_desc = desc ; e_loc = loc } as e ) = let ty = match desc with | Econst ( i ) -> immediate i | Elocal ( x ) -> let { t_typ = typ ; t_sort = sort } = var loc h x in sort_less_than loc sort expected_k ; typ | Eglobal { lname = lname } -> let qualid , typ_instance , ty = global_with_in... |
let no_unbounded_name loc free_in_ty ty = if not ( S . is_empty free_in_ty ) then let n = S . choose free_in_ty in error loc ( Esize_parameter_cannot_be_generalized ( n , ty ) ) else ty |
let funtype loc expected_k pat_list ty_list ty_res = let rec arg pat_list ty_list fv_in_ty_res = match pat_list , ty_list with | [ ] , [ ] -> [ ] , fv_in_ty_res | pat :: pat_list , ty_arg :: ty_list -> let ty_res_list , fv_in_ty_res = arg pat_list ty_list fv_in_ty_res in let fv_pat = Vars . fv_pat S . empty S . empty p... |
let constdecl f is_static e = let expected_k = if is_static then Tstatic ( true ) else Tdiscrete ( false ) in Zmisc . push_binding_level ( ) ; let ty = expression expected_k Env . empty e in Zmisc . pop_binding_level ( ) ; let tys = Ztypes . gen ( not ( expansive e ) ) ty in tys |
let fundecl loc f ( { f_kind = k ; f_atomic = is_atomic ; f_args = pat_list ; f_body = e } as body ) = Zmisc . push_binding_level ( ) ; let expected_k = Interface . kindtype k in let h0 = env_of_pattern_list expected_k Env . empty pat_list in body . f_env <- h0 ; let ty_p_list = List . map ( fun _ -> new_var ( ) ) pat_... |
let implementation ff is_first impl = try match impl . desc with | Econstdecl ( f , is_static , e ) -> let tys = constdecl f is_static e in if is_first then Interface . add_type_of_value ff impl . loc f is_static tys else Interface . update_type_of_value ff impl . loc f is_static tys | Efundecl ( f , body ) -> let tys ... |
let implementation_list ff is_first impl_list = Zmisc . no_warning := not is_first ; List . iter ( implementation ff is_first ) impl_list ; Zmisc . no_warning := not is_first ; impl_list |
let badwords = [ " abandonned " ; " abandonning " ; " abbrevation " ; " abbrevations " ; " abigious " ; " abilties " ; " abilty " ; " abitrate " ; " abolute " ; " abov " ; " absense " ; " absolut " ; " absoulte " ; " acccept " ; " acccepted " ; " acccepting " ; " acccepts " ; " acccess " ; " acceleratoin " ; " acceller... |
let regexp = let make_regexp word = " \\ b " ^ Str . quote word ^ " \\ b " in Str . regexp @@ String . concat " " \\| @@ List . map make_regexp badwords |
let string_search re s start = try ignore ( Str . search_forward re s start ) ; true with Not_found -> false |
let find s = if string_search regexp s 0 then Some ( Str . matched_string s ) else None |
module Seq = struct include Seq let of_list l = let rec aux l ( ) = match l with | [ ] -> Seq . Nil | x :: tail -> Seq . Cons ( x , aux tail ) in aux l let to_rev_list gen = fold_left ( fun acc x -> x :: acc ) [ ] gen let to_list gen = List . rev ( to_rev_list gen ) end |
let map_3 f ( x , y , z ) = ( x , y , f z ) |
module T = struct type ( ' a , ' b ) conv = { to_ : ' a -> ' b ; from_ : ' b -> ' a ; } type ' a raw = | Regexp : Re . t * Re . re Lazy . t -> string raw | Conv : ' a raw * ( ' a , ' b ) conv -> ' b raw | Opt : ' a raw -> ( ' a option ) raw | Alt : ' a raw * ' b raw -> [ ` Left of ' a | ` Right of ' b ] raw | Seq : ' a... |
type ' a t = ' a T . raw |
let regex x : _ t = let re = lazy Re . ( compile @@ whole_string @@ no_group x ) in Regexp ( x , re ) |
let pcre s = regex @@ Re . Pcre . re s |
let conv to_ from_ x : _ t = Conv ( x , { to_ ; from_ } ) |
let seq a b : _ t = Seq ( a , b ) |
let alt a b : _ t = Alt ( a , b ) |
let prefix x a : _ t = Prefix ( x , a ) |
let suffix a x : _ t = Suffix ( a , x ) |
let opt a : _ t = Opt a |
module Infix = struct let ( ) <|> = alt let ( ) <&> = seq let ( ) *> = prefix let ( <* ) = suffix end |
let rep x : _ t = Rep x |
let rep1 x = x <&> rep x |
let modifier f re : _ t = Mod ( f , re ) |
let word re = modifier Re . word re |
let whole_string re = modifier Re . whole_string re |
let longest re = modifier Re . longest re |
let shortest re = modifier Re . shortest re |
let first re = modifier Re . first re |
let greedy re = modifier Re . greedy re |
let non_greedy re = modifier Re . non_greedy re |
let nest re = modifier Re . nest re |
module Regex = struct open ! Re let pos_int = rep1 digit let int = seq [ opt ( char ' ' ) - ; pos_int ] let float = seq [ opt ( char ' ' ) - ; rep1 digit ; opt ( seq [ char ' . ' ; rep digit ] ) ] let bool = alt [ str " true " ; str " false " ] end |
let unit s re = conv ( fun _ -> ( ) ) ( fun ( ) -> s ) ( regex re ) |
let start = unit " " Re . start |
let stop = unit " " Re . stop |
let str s = unit s ( Re . str s ) |
let char c = let s = String . make 1 c in unit s ( Re . char c ) |
let blanks = unit " " ( Re . rep Re . blank ) |
let pos_int = conv int_of_string string_of_int ( regex Regex . pos_int ) |
let int = conv int_of_string string_of_int ( regex Regex . int ) |
let float = conv float_of_string string_of_float ( regex Regex . float ) |
let bool = conv bool_of_string string_of_bool ( regex Regex . bool ) |
let list e = conv Seq . to_list Seq . of_list ( rep e ) |
let terminated_list ~ sep e = list ( e <* sep ) |
let separated_list ~ sep e = let e = opt ( e <&> list ( sep *> e ) ) in let to_ = function None -> [ ] | Some ( h , t ) -> ( h :: t ) and from_ = function [ ] -> None | h :: t -> Some ( h , t ) in conv to_ from_ e |
let rec witnesspp : type a . Format . formatter -> a t -> unit = fun ppf tre -> let open T in match tre with | Regexp ( re , _ ) -> Format . pp_print_string ppf @@ Re . witness re | Conv ( tre , _ ) -> witnesspp ppf tre | Opt _ -> ( ) | Alt ( tre1 , _ ) -> witnesspp ppf tre1 | Seq ( tre1 , tre2 ) -> witnesspp ppf tre1 ... |
let rec pprep f ppf seq = match seq ( ) with | Seq . Nil -> ( ) | Cons ( x , seq ) -> f ppf x ; pprep f ppf seq |
let rec evalpp : type a . a t -> Format . formatter -> a -> unit = fun tre ppf -> let open T in match tre with | Regexp ( _ , lazy cre ) -> begin function v -> if not @@ Re . execp cre v then invalid_arg @@ Printf . sprintf " Tyre . eval : regexp not respected by " \% s " . " \ v ; pstr ppf v end | Conv ( tre , conv ) ... |
let eval tre = Format . asprintf " % a " ( evalpp tre ) |
let rec build : type a . int -> a t -> int * a T . wit * Re . t = let open ! Re in let open T in fun i -> function | Regexp ( re , _ ) -> ( i + 1 ) , Lit i , group @@ no_group re | Conv ( e , conv ) -> let i ' , w , re = build i e in i ' , Conv ( w , conv ) , re | Opt e -> let i ' , w , ( id , re ) = map_3 mark @@ buil... |
type ' + r route = Route : ' a t * ( ' a -> ' r ) -> ' r route |
let route re f = Route ( re , f ) |
type ' r wit_route = WRoute : Re . Mark . t * ' a T . wit * ( ' a -> ' r ) -> ' r wit_route |
let rec build_route_aux i rel wl = function | [ ] -> List . rev rel , List . rev wl | Route ( tre , f ) :: l -> let i ' , wit , re = build i tre in let id , re = Re . mark re in let w = WRoute ( id , wit , f ) in build_route_aux i ' ( re :: rel ) ( w :: wl ) l |
let build_route l = build_route_aux 1 [ ] [ ] l |
let rec extract_route ~ original wl subs = match wl with | [ ] -> assert false | WRoute ( id , wit , f ) :: wl -> if Re . Mark . test subs id then f ( extract ~ original wit subs ) else extract_route ~ original wl subs |
type ' r info = | One of ' r T . wit | Routes of ' r wit_route list |
type ' a re = { info : ' a info ; cre : Re . re } |
let compile tre = let _ , wit , re = build 1 tre in let cre = Re . compile re in { info = One wit ; cre } |
let route l = let rel , wl = build_route l in let cre = Re . compile @@ Re . alt rel in { info = Routes wl ; cre } |
type ' a error = [ | ` NoMatch of ' a re * string | ` ConverterFailure of exn ] |
let extract_with_info ~ info ~ original subs = match info with | One w -> extract ~ original w subs | Routes wl -> extract_route ~ original wl subs match Re . exec_opt ? pos ? len cre original with | None -> Result . Error ( ` NoMatch ( tcre , original ) ) | Some subs -> try Result . Ok ( extract_with_info ~ info ~ ori... |
let execp ? pos ? len { cre ; _ } original = Re . execp ? pos ? len cre original |
let all_seq ? pos ? len { info ; cre } original = let seq = Re . Seq . all ? pos ? len cre original in let get_res subs = extract_with_info ~ info ~ original subs in Seq . map get_res seq |
let all ? pos ? len tcre original = try Result . Ok ( Seq . to_list @@ all_seq ? pos ? len tcre original ) with exn -> Result . Error ( ` ConverterFailure exn ) |
let sexp ppf s fmt = Format . fprintf ppf ( " [ @< 3 ( >% s @ " ^^ fmt " ) ] " ) ^^@ s |
let rec pp_list pp ppf = function | [ ] -> ( ) | [ v ] -> pp ppf v | v :: vs -> pp ppf v ; Format . pp_print_space ppf ( ) ; pp_list pp ppf vs |
let rec pp : type a . _ -> a t -> unit = fun ppf -> let open T in function | Regexp ( re , _ ) -> sexp ppf " Re " " % a " Re . pp re | Conv ( tre , _ ) -> sexp ppf " Conv " " % a " pp tre | Opt tre -> sexp ppf " Opt " " % a " pp tre | Alt ( tre1 , tre2 ) -> sexp ppf " Alt " " % a @ % a " pp tre1 pp tre2 | Seq ( tre1 , ... |
let rec pp_wit : type a . _ -> a T . wit -> unit = fun ppf -> let open T in function | Lit i -> sexp ppf " Lit " " % i " i | Conv ( tre , _ ) -> sexp ppf " Conv " " % a " pp_wit tre | Opt ( _ , tre ) -> sexp ppf " Opt " " % a " pp_wit tre | Alt ( _ , tre1 , tre2 ) -> sexp ppf " Alt " " % a @ % a " pp_wit tre1 pp_wit tr... |
let pp_wit_route : type a . _ -> a wit_route -> unit = fun ppf ( WRoute ( _ , w , _ ) ) -> pp_wit ppf w |
let pp_re ppf = function | { info = One w ; cre } -> sexp ppf " One " " % a @ % a " Re . pp_re cre pp_wit w | { info = Routes wl ; cre } -> sexp ppf " Route " " % a @ % a " Re . pp_re cre ( pp_list pp_wit_route ) wl |
let pp_error ppf : _ error -> unit = function | ` NoMatch ( re , s ) -> Format . fprintf ppf " ` NoMatch ( % a , % s ) " pp_re re s | ` ConverterFailure exn -> Format . pp_print_string ppf @@ Printexc . to_string exn |
module Internal = struct include T let to_t x = x let from_t x = x let build = build let extract = extract end |
module MakeTo ( C : sig type ' a elt val elt : ' a elt -> Dom . node Js . t type ' a elt = ' a C . elt let rebuild_node _ x = Js . Unsafe . coerce ( C . elt x ) let of_element elt = rebuild_node " of_element " elt let of_node elt = rebuild_node " of_node " elt let of_pcdata elt = rebuild_node " of_pcdata " elt let of_h... |
module MakeOf ( C : sig type ' a elt val elt : Dom . node Js . t -> ' a elt type ' a elt = ' a C . elt let rebuild_node _ x = C . elt ( Js . Unsafe . coerce x ) let of_element elt = rebuild_node " of_element " elt let of_html elt = rebuild_node " of_html " elt let of_head elt = rebuild_node " of_head " elt let of_link ... |
module type OF = sig type ' a elt val of_element : Dom_html . element Js . t -> ' a elt val of_html : Dom_html . htmlElement Js . t -> [ > Html_types . html ] elt val of_head : Dom_html . headElement Js . t -> [ > Html_types . head ] elt val of_link : Dom_html . linkElement Js . t -> [ > Html_types . link ] elt val of_... |
module type TO = sig type ' a elt val of_element : ' a elt -> Dom_html . element Js . t val of_node : ' a elt -> Dom . node Js . t val of_pcdata : [ < Html_types . pcdata ] elt -> Dom . text Js . t val of_html : [ < Html_types . html ] elt -> Dom_html . htmlElement Js . t val of_head : [ < Html_types . head ] elt -> Do... |
let js_string_of_float f = ( Js . number_of_float f ) ## toString |
let js_string_of_int i = ( Js . number_of_float ( float_of_int i ) ) ## toString |
module type XML = Xml_sigs . T with type uri = string and type event_handler = Dom_html . event Js . t -> bool and type mouse_event_handler = Dom_html . mouseEvent Js . t -> bool and type keyboard_event_handler = Dom_html . keyboardEvent Js . t -> bool and type elt = Dom . node Js . t |
module Xml = struct module W = Xml_wrap . NoWrap type ' a wrap = ' a type ' a list_wrap = ' a list type uri = string let uri_of_string s = s let string_of_uri s = s type aname = string type event_handler = Dom_html . event Js . t -> bool type mouse_event_handler = Dom_html . mouseEvent Js . t -> bool type keyboard_even... |
module Xml_Svg = struct include Xml let leaf ( ? a = [ ] ) name = let e = Dom_html . document ## createElementNS Dom_svg . xmlns ( Js . string name ) in attach_attribs e a ; ( e :> Dom . node Js . t ) let node ( ? a = [ ] ) name children = let e = Dom_html . document ## createElementNS Dom_svg . xmlns ( Js . string nam... |
module Svg = Svg_f . Make ( Xml_Svg ) |
module Html = Html_f . Make ( Xml ) ( Svg ) |
module To_dom = Tyxml_cast . MakeTo ( struct type ' a elt = ' a Html . elt let elt = Html . toelt end ) |
module Of_dom = Tyxml_cast . MakeOf ( struct type ' a elt = ' a Html . elt let elt = Html . tot end ) |
module Register = struct let removeChildren ( node : # Dom . element Js . t ) = let l = node . ## childNodes in for i = 0 to l . ## length - 1 do Js . Opt . iter ( l ## item i ) ( fun x -> ignore ( node ## removeChild x ) ) done let add_to ( ? keep = true ) node content = if not keep then removeChildren node ; List . i... |
module Wrap = struct type ' a t = ' a React . signal type ' a tlist = ' a ReactiveData . RList . t type ( ' a , ' b ) ft = ' a -> ' b let return = React . S . const let fmap f = React . S . map f let nil ( ) = ReactiveData . RList . empty let singleton = ReactiveData . RList . singleton_s let cons x xs = ReactiveData .... |
module Util = struct open ReactiveData open RList let insertAt dom i x = let nodes = dom . ## childNodes in assert ( i <= nodes . ## length ) ; if i = nodes . ## length then ignore ( dom ## appendChild ( x :> Dom . node Js . t ) ) else ignore ( dom ## insertBefore x ( nodes ## item i ) ) let merge_one_patch ( dom : Dom... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.