text stringlengths 12 786k |
|---|
let ttoken = TypApp ( tctoken , [ ] ) |
let ttokengadt a = TypApp ( tctokengadt , [ a ] ) |
let ttokengadtdata token = " T_ " ^ token |
let tokentypedef grammar = let typerhs = match Settings . token_type_mode with | Settings . TokenTypeOnly | Settings . TokenTypeAndCode -> TDefSum ( List . map ( fun ( tok , typo ) -> { dataname = tok ; datavalparams = ( match typo with None -> [ ] | Some t -> [ TypTextual t ] ... |
let tokengadtdef grammar = assert Settings . inspection ; let param , typerhs = match Settings . token_type_mode with | Settings . TokenTypeOnly | Settings . TokenTypeAndCode -> let param = " _ " in param , TDefSum ( { dataname = ttokengadtdata " error " ; datavalparams = [ ] ; ... |
let produce_tokentypes grammar = match Settings . token_type_mode with | Settings . TokenTypeOnly -> let i = tokentypedef grammar @ MList . ifnlazy Settings . inspection ( fun ( ) -> tokengadtdef grammar ) in let module P = Printer . Make ( struct let f = open_out ( Settings . base ^ " ... |
let tokenprefix id = match Settings . token_type_mode with | Settings . CodeOnly m -> m ^ " . " ^ id | Settings . TokenTypeAndCode -> id | Settings . TokenTypeOnly -> id |
let tokengadtdata token = tokenprefix ( ttokengadtdata token ) |
type token = Parser . token = | WITH | WHILE | WHEN | VIRTUAL | VAL | UNDERSCORE | UIDENT of string | TYPE | TRY | TRUE | TO | TILDE | THEN | STRUCT | STRING of ( string * Location . t * string option ) | STAR | SIG | SEMISEMI | SEMI | RPAREN | REC | RBRACKET | RBRACE | QUOTED_STRING... |
let of_compiler_libs x = x |
module State ( User : ANY ) = struct type t = { indent : Indent . t ; range : Position . range option ; user : User . t ; } let make ( user : User . t ) : t = { indent = Indent . initial ; range = None ; user } let check_position ( column : int ) ( s : t ) : Ind... |
module Make ( User : ANY ) ( Token : ANY ) ( Final : ANY ) ( Semantic : ANY ) = struct module State = State ( User ) module Tok = struct type t = Token . t Located . t end module Expect = struct type t = String . t * Indent . violation option end module Basic = Generic . Make (... |
module Stable = struct module V1 = struct type t = | Token_owned of { disable_new_accounts : bool } | Not_owned of { account_disabled : bool } [ @@ deriving compare , equal , sexp , hash , yojson ] yojson let to_latest = Fn . id end end ] end |
let default = Not_owned { account_disabled = false } |
let to_input t = let bs = match t with | Token_owned { disable_new_accounts } -> [ true ; disable_new_accounts ] | Not_owned { account_disabled } -> [ false ; account_disabled ] in Random_oracle . Input . Chunked . packed ( Field . project bs , List . length bs ) bs |
type var = { token_owner : Boolean . var ; token_locked : Boolean . var } |
let var_of_t = function | Token_owned { disable_new_accounts } -> { token_owner = Boolean . true_ ; token_locked = Boolean . var_of_value disable_new_accounts } | Not_owned { account_disabled } -> { token_owner = Boolean . false_ ; token_locked = Boolean . var_of_value account_disabled } ... |
let typ : ( var , t ) t Typ . t = let open Typ in Boolean . typ * Boolean . typ |> Typ . transport_var ~ back ( : fun ( token_owner , token_locked ) token_locked -> { token_owner ; token_locked } ) ~ there ( : fun { token_owner ; token_locked } -> ( token_owner , token_lo... |
let var_to_input { token_owner ; token_locked } = let bs = [ token_owner ; token_locked ] in Random_oracle . Input . Chunked . packed ( Field . Var . project bs , List . length bs ) bs [ %% endif ] endif |
let gen = let open Quickcheck . Generator . Let_syntax in let % bind token_owner = Quickcheck . Generator . bool in let % map token_locked = Quickcheck . Generator . bool in if token_owner then Token_owned { disable_new_accounts = token_locked } else Not_owned { account_disabled = token_locked } |
type t = [ ` Int of int | ` Float of float | ` String of string | ` Bool of bool | ` List of t list | ` Assoc of ( string * t ) t list ] |
let rec of_toml_table v : t = let f ( k , v ) v = ( Toml . Types . Table . Key . to_string k , of_toml_value v ) v in let pairs = List . map f ( Toml . Types . Table . bindings v ) v in ` Assoc pairs | TBool b -> ` Bool b | TInt i -> ` Int i | TFloat f -> ` Float f | TS... |
let source = let module D = CConv . Decode in let rec src = { D . emit = ( fun dec ( x : t ) t -> match x with | ` Bool b -> dec . D . accept_bool src b | ` Int i -> dec . D . accept_int src i | ` Float f -> dec . D . accept_float src f | ` String s -> dec . D . accept_string src s ... |
let decode dec x = CConv . decode source dec ( of_toml_table x ) x |
let decode_exn dec x = CConv . decode_exn source dec ( of_toml_table x ) x |
type metadata = { name : string ; source : string ; license : string ; synopsis : string ; description : string ; lifecycle : string ; } |
let path = Fpath . v " data / tools . yml " |
module Lifecycle = struct type t = [ ` Incubate | ` Active | ` Sustain | ` Deprecate ] let to_string = function | ` Incubate -> " incubate " | ` Active -> " active " | ` Sustain -> " sustain " | ` Deprecate -> " deprecate " let of_string = function | " incubate " ... |
type t = { name : string ; slug : string ; source : string ; license : string ; synopsis : string ; description : string ; lifecycle : Lifecycle . t ; } |
let parse s = let yaml = Utils . decode_or_raise Yaml . of_string s in match yaml with | ` O [ ( " tools " , ` A xs ) xs ] -> Ok ( List . map ( fun x -> Utils . decode_or_raise metadata_of_yaml x ) x xs ) xs | _ -> Error ( ` Msg " Expected list of tools ) " |
let decode s = let yaml = Utils . decode_or_raise Yaml . of_string s in match yaml with | ` O [ ( " tools " , ` A xs ) xs ] -> List . map ( fun x -> try let ( metadata : metadata ) metadata = Utils . decode_or_raise metadata_of_yaml x in let lifecycle = match Lifecycle . of_string met... |
let all ( ) = let content = Data . read " tools . yml " |> Option . get in decode content |
let pp_lifecycle ppf v = Fmt . pf ppf " % s " ( match v with | ` Incubate -> " ` Incubate " | ` Active -> " ` Active " | ` Sustain -> " ` Sustain " | ` Deprecate -> " ` Deprecate ) " |
let pp ppf v = Fmt . pf ppf { | { name = % a ; slug = % a ; source = % a ; license = % a ; synopsis = % a ; description = % a ; lifecycle = % a } } | Pp . string v . name Pp . string v . slug Pp . string v . source Pp . string v . license Pp . string v . synopsis Pp . str... |
let pp_list = Pp . list pp |
let template ( ) = Format . asprintf { | |
type lifecycle = [ ` Incubate | ` Active | ` Sustain | ` Deprecate ] |
type t = { name : string ; slug : string ; source : string ; license : string ; synopsis : string ; description : string ; lifecycle : lifecycle } |
let all = % a } | pp_list ( all ( ) ) |
let tool_messages_clicked = new tool_messages_clicked ( ) in let tool_hmessages_clicked = new tool_hmessages_clicked ( ) in let toolbar = GButton . toolbar ~ style ` : ICONS ( ) in let _ = toolbar # set_icon_size ` MENU in let tool_new_file = GButton . tool_button ~ label " : New " ( ... |
type icon = P of GdkPixbuf . pixbuf | S of GtkStock . id | N |
type kind = B | BM | M | I |
type ' a item = { id : int ; tag : ' a ; kind : kind ; pixbuf : icon ; label : string ; check : GMenu . check_menu_item ; mutable tool_widget : GObj . widget option ; mutable tool_callback : ( unit -> unit ) ; mutable tool_callback_menu : ( string option ref * GMenu . menu ... |
let pixbuf_empty = let pixbuf = GdkPixbuf . create ~ width : 1 ~ height : 16 ~ has_alpha : true ( ) in GdkPixbuf . fill pixbuf 0l ; let pixbuf = GdkPixbuf . add_alpha ~ transparent ( : 0 , 0 , 0 ) pixbuf in pixbuf |
let specs ~ browser = let editor : Editor . editor = browser # editor in [ 100 , ` NEW_FILE , B , P Icons . new_file , " New File . . . " , ( fun _ -> browser # dialog_file_new ( ) ) , None ; 200 , ` OPEN_FILE , B , P Icons . open_file , " Open File . . ... |
let items ~ browser = let items = List . map ( fun ( id , tag , kind , pixbuf , label , tool_callback , tool_callback_menu ) -> { id ; tag ; kind ; pixbuf ; label ; check = GMenu . check_menu_item ~ active : false ( ) ; tool_widget = None ; tool_callback ; tool_callba... |
let create_tool ( ~ toolbox : GPack . box ) item = let image = match item . pixbuf with | P _ when item . tag = ` VIEW_MESSAGES -> Some ( GMisc . image ~ pixbuf : Icons . paned_bottom_large ( ) ) | P pixbuf -> Some ( GMisc . image ~ pixbuf ( ) ) | S stock -> Some ( GMi... |
let create_item ~ menu ( ~ toolbox : GPack . box ) ~ pos item = menu # add ( item . check :> GMenu . menu_item ) ; item . check # event # connect # button_release ~ callback : begin fun _ -> item . check # set_active ( not item . check # active ) ; true ; end |> ignore ; ... |
let populate ~ browser ~ packing = let toolbox = GPack . hbox ~ border_width : 2 ~ spacing : 3 ~ packing ( ) in let button_menu = GButton . button ~ relief ` : NONE ~ packing : toolbox # pack ( ) in button_menu # misc # set_name " smallbutton " ; button_menu # set_focus_on_click ... |
let space_re = Str . regexp " " + |
let edges = Hashtbl . create 128 |
let edge_count = Hashtbl . create 128 |
let chop s = try let i = String . rindex s ' . ' in String . sub s 0 i with Not_found -> s |
let add_edge target dep = if target <> dep then ( Hashtbl . replace edges dep ( target :: ( try Hashtbl . find edges dep with Not_found -> [ ] ) ) ; Hashtbl . replace edge_count target ( 1 + try Hashtbl . find edge_count target with Not_found -> 0 ) ; if not ( Hashtbl . mem edg... |
let sort l = let res = ref [ ] in List . iter ( fun ( target , deps ) -> let target = chop target in if not ( Hashtbl . mem edge_count target ) then Hashtbl . add edge_count target 0 ; List . iter ( fun dep -> add_edge target ( chop dep ) ) deps ) l ; let q = Queue . creat... |
let _ = let ch = open_in Sys . argv . ( 1 ) in let lst = ref [ ] in ( try while true do let l = input_line ch in let l = Str . split space_re l in match l with | target :: " " : :: deps -> lst := ( target , deps ) :: ! lst | _ -> assert false done with End_of_file -> ( ) ... |
module Make ( Structure : Structure . S ) = struct open Structure ; value empty_entry ename _ _ _ = raise ( Stream . Error ( " entry [ " ^ ename ^ " ] is empty " ) ) ; value is_level_labelled n lev = match lev . lname with [ Some n1 -> n = n1 | None -> False ] ; valu... |
let json_format = !!% " % a . " @ Tiny_json . Json . format |
let ocaml_format_with f = !!% " % a . " @ ( Ocaml . format_no_poly_with f ) |
let get_current_user o = let open Job in do_ ; x <-- Test . login o ; return ( object method id = x # id method username = x # username end ) |
let uploadable_by_name s = let _ , ext = Filename . split_extension s in match String . lowercase ext with | " . jpg " | " . jpeg " | " . gif " | " . png " | " . tif " | " . tiff " -> Some ` Image | " . wmv " | " . mp4 " | " . avi " | " . m... |
let delete_dups_in_sets o = let open Job in do_ ; ( _info , psets ) <-- Photosets . getList ' o ; flip mapM_ psets & fun set -> do_ ; let set_id = set # id in let set_title = set # title in [ % p ? ( _ , photos ) ] <-- Photosets . getPhotos ' set_id o ; let photos = List . ... |
let uploads ( ? remove_non_local = false ) ~ photoset ~ existing img_files o = let open Job in do_ ; ( _info , psets ) <-- Photosets . getList ' o ; ( ) ; !!% " Got existing photosets ( % d ) . " @ & List . length psets ; let psid_opt = ref ( List . find_opt ( fun... |
let trace = ref false |
let t_int parameters x = if Remanent_parameters . get_trace parameters || ! trace then Loggers . fprintf ( Remanent_parameters . get_logger parameters ) " % i " x |
let t_string parameters x = if Remanent_parameters . get_trace parameters || ! trace then Loggers . fprintf ( Remanent_parameters . get_logger parameters ) " % s " x |
let comp_pair ( a , b ) ( x , y ) = match ( a < x , a = x , b < y ) with true , _ , _ -> ( - 1 ) |
let rec list_it f l b = match l with t :: q -> list_it f q ( f t b ) |
let rec true_map x y = |
let max_of_list parameters error list = match list with | [ ] -> Exception . warn parameters error __POS__ Exit None | t :: q -> error , Some ( List . fold_left max t q ) |
let sum_list list = List . fold_left ( fun a b -> a + b ) 0 list |
let rec member x l = match l with [ ] -> false | a :: b -> if a = x then true else member x b ; ; |
let rec member2 x l = match l with [ ] -> false ( | a , _ ) :: b -> if a = x then true else member2 x b ; ; |
let rec all_differents liste = match liste with a :: b -> if ( member a b ) then false else ( all_differents b ) | [ ] -> true ; ; |
let rec dolist l a = match l with t :: q -> ( dolist q ( t a ) ) | [ ] -> a ; ; |
let concat liste1 liste2 = let rec aux liste1 liste2 = match liste1 with a :: b -> aux b ( a :: liste2 ) | [ ] -> liste2 in aux ( rev liste1 ) liste2 ; ; |
let applati liste = let rec aux1 l rep = match l with a :: b -> aux1 b ( a :: rep ) | [ ] -> rep in let rec aux2 l rep = match l with a :: b -> aux2 b ( aux1 a rep ) | [ ] -> rep in rev ( aux2 liste [ ] ) ; ; |
let rec forall p l = match l with a :: b -> if ( p a ) then ( forall p b ) else false | [ ] -> true ; ; |
let rec correspondance parameters error ancien nouveau x = match ancien , nouveau with | a :: _ , p :: _ when a = x -> error , Some p | _ :: b , _ :: q -> correspondance parameters error b q x | [ ] , [ ] -> error , Some x | _ -> Exception . warn parameters error __POS__ Exit N... |
let transfert parameters error ancien nouveau liste = let rec aux parameters error l = match l with [ ] -> error , [ ] | a :: b -> let error , h = correspondance parameters error ancien nouveau a in let error , tl = aux parameters error b in error , h :: tl in aux parameters error liste ; ; |
let tr parameters error ancien nouveau id = match ( transfert parameters error ancien nouveau [ id ] ) with error , [ res ] -> error , res | error , _ -> Exception . warn parameters error __POS__ Exit None |
let paire_of_list liste1 liste2 rep = let rec aux1 x l2 rep = match l2 with a :: b -> aux1 x b ( ( x , a ) :: rep ) | [ ] -> rep in let rec aux2 l1 l2 rep = match l1 with a :: b -> aux2 b l2 ( aux1 a l2 rep ) | [ ] -> rep in aux2 liste1 liste2 rep ; ; |
let produit_predicat p i j = match i , j with ( a , b ) , ( c , d ) -> ( ( p a c ) || ( ( a = c ) && ( p b d ) ) ) ; ; |
let union_list p liste1 liste2 = let rec aux liste1 liste2 sol = match liste1 , liste2 with a :: b , t :: q when a = t -> aux b q ( t :: sol ) | a :: b , t :: _q when ( p a t ) -> aux b liste2 ( a :: sol ) | _a :: _b , t :: q -> aux liste1 q ( t :: sol ) | a :: b , [ ] ... |
let intersec_list p liste1 liste2 = let rec aux liste1 liste2 sol = match liste1 , liste2 with a :: b , t :: q -> if ( a = t ) then aux b q ( a :: sol ) else ( if ( p a t ) then aux b liste2 sol else aux liste1 q sol ) | _ -> ( rev sol ) in aux liste1 liste2 [ ] |
let ajoute t liste = let rec aux liste rep = match liste with a :: b -> aux b ( ( concat t a ) :: rep ) | [ ] -> rep in aux ( rev liste ) [ ] |
let flat_map f l = let rec aux l rep = match l with a :: b -> aux b ( ( f a ) @ rep ) | [ ] -> rep in aux ( rev l ) [ ] |
let flat_map_zip f l = let rec aux l rep1 rep2 = match l with a :: b -> let ( c , d ) = f a in aux b ( c @ rep1 ) ( d @ rep2 ) | [ ] -> rep1 , rep2 in aux ( rev l ) [ ] [ ] |
let produit_list liste1 liste2 = flat_map ( fun x -> ajoute x liste2 ) liste1 |
let rec mix_list liste = match liste with [ ] -> [ [ ] ] | t :: q -> produit_list t ( mix_list q ) |
let insert_list p x liste1 = let rec vide reste fait = match reste with a :: b -> vide b ( a :: fait ) [ ] | -> fait in let rec aux reste vue = match reste with a :: b -> if ( p a x ) then ( aux b ( a :: vue ) ) else ( vide ( x :: vue ) reste ) | [ ] -> vide ( x :: vue )... |
let list_of_table h = let liste = ref [ ] in ( Hashtbl . iter ( fun a -> fun b ( -> liste ( := a , b ) ( ::! liste ) ) ) h ; ! liste ) |
let copy_table h = let rep = Hashtbl . create 1 in ( Hashtbl . iter ( fun a -> fun b ( -> Hashtbl . add rep a b ) ) h ; rep ) |
let insert_sort p l k = let rec aux l rep = match l with | t :: q when ( p t k ) -> aux q ( t :: rep ) | t :: _q when t = k -> concat ( List . rev rep ) l | _ -> concat ( List . rev rep ) ( k :: l ) in aux l [ ] |
let merge p l k = let rec aux l1 l2 rep = match l1 , l2 with t :: q , a :: _b when p t a -> aux q l2 ( t :: rep ) | t :: q , a :: b when p a t -> aux ( t :: q ) b ( a :: rep ) | t :: q , _a :: b -> aux q b ( t :: rep ) | t :: q , [ ] -> aux q l2 ( t :: rep ) | [... |
let sub_list p l k = let rec aux l rep = match l with t :: q when t = k -> concat ( List . rev rep ) q in aux l [ ] |
let vide f l = let rec aux l rep = match l with t :: q when ( f t ) -> aux q rep | t :: q -> aux q ( t :: rep ) | _ -> ( List . rev rep ) in aux l [ ] |
let filtre f l = vide ( fun x -> not ( f x ) ) l |
let rev l = let rec aux res sol = match res with [ ] -> sol | a :: b -> aux b ( a :: sol ) |
let flap_map parameters error f l = let n = Working_list_imperative . make ( Remanent_parameters . get_empty_hashtbl_size parameters ) in let rec aux l = match l with t :: q -> ( Working_list_imperative . push ( f t ) n ; aux q ) | [ ] -> ( ) in List . iter aux l ; error , Worki... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.