text stringlengths 0 601k |
|---|
type word = | Any | A of string | Kind of string | Level of int tag : tag ; word : word ; tag_name : string ; } |
type pattern = { descr : descr } |
let string_of_descr ( x : descr ) = match x . word with | Any -> x . tag_name | Kind s -> x . tag_name ^ " " ^ s | A s -> Printf . sprintf " % S " s | Level d -> x . tag_name ^ Printf . sprintf " Level % d " d |
let string_of_pattern ( x : pattern ) = string_of_descr x . descr |
let eq_pattern ( x : pattern ) ( y : pattern ) : bool = x . descr = y . descr |
let quot_expand ( expander ' : a expand_fun ) ( x : quot ) = let loc = Location_util . join { x . loc with loc_start = { x . loc . loc_start with pos_cnum = x . loc . loc_start . pos_cnum + x . shift } } in let content = String . sub x . txt x . shift ( String . length x . txt - x . retract - x . shift ) in expander lo... |
let pp_print_quotation : Format . formatter -> quotation -> unit = fun fmt ( ` Quot x ) -> Format . fprintf fmt " [ @< 1 ( ` > Quot % a ) ] " @ pp_print_quot x |
let pp_print_dir_quotation : Format . formatter -> dir_quotation -> unit = fun fmt ( ` DirQuotation x ) -> Format . fprintf fmt " [ @< 1 ( ` > DirQuotation % a ) ] " @ pp_print_quot x |
let pp_print_t ( fmt : Format . formatter ) ( x : t ) : unit = match x with | ` Inf x -> Format . fprintf fmt " [ @< 1 ( ` > Inf @ % a ) ] " @ Format . pp_print_string x . txt | ` Pre x -> Format . fprintf fmt " [ @< 1 ( ` > Pre @ % a ) ] " @ Format . pp_print_string x . txt | ` Key x -> Format . fprintf fmt " [ @< 1 (... |
type stream = t Streamf . t |
type ' a parse = stream -> ' a |
type ' a lex = Locf . t -> char Streamf . t -> ' a |
type filter = stream -> stream |
let to_string = Formatf . to_string pp_print_t |
let print ppf x = Format . pp_print_string ppf ( to_string x ) |
let strip ( x : t ) : Obj . t = Obj . field ( Obj . repr x ) 1 |
let get_tag ( x : t ) : tag = ( Obj . magic ( Obj . field ( Obj . repr x ) 0 ) : tag ) |
let destruct ( x : t ) = ( ( Obj . magic ( Obj . field ( Obj . repr x ) 0 ) : tag ) , Obj . field ( Obj . repr x ) 1 ) |
let get_string ( x : t ) : string = match x with | ` Pre x | ` Key x | ` Lid x | ` Uid x | ` Int x | ` Int32 x | ` Int64 x | ` Nativeint x | ` Flo x | ` Chr x | ` Str x | ` Label x | ` Optlabel x | ` EOI x -> x . txt | ` Quot x -> x . txt | ` DirQuotation x -> x . txt | ` Ant x -> x . txt | ` Inf x -> x . txt |
let get_loc ( x : t ) = match x with | ` Key x | ` Lid x | ` Uid x | ` Int x | ` Int32 x | ` Int64 x | ` Nativeint x | ` Flo x | ` Chr x | ` Pre x | ` Str x | ` Label x | ` Optlabel x | ` EOI x -> x . loc | ` Ant x -> x . loc | ` Quot x -> x . loc | ` DirQuotation x -> x . loc | ` Inf x -> x . loc |
let empty_name : name = { domain = ` Sub [ ] ; name = " " } |
let name_of_string s : name = match s . [ 0 ] with | ' . ' -> ( match List . rev @@ List . filter Stringf . not_empty ( Stringf . nsplit s " . " ) with | x :: xs -> { domain = ` Absolute ( List . rev xs ) ; name = x } | _ -> assert false ) ' | A ' . . ' Z ' -> ( match List . rev ( List . filter Stringf . not_empty ( St... |
let match_token ( x : pattern ) = let tag = x . descr . tag in let word = x . descr . word in fun ( token_tag , obj ) -> ( tag = token_tag && ( match word with | Any -> true | Kind s -> ( Obj . magic ( Obj . field obj 3 ) : string ) = s | A s -> ( Obj . magic ( Obj . field obj 1 ) : string ) = s | Level i -> ( Obj . ma... |
type t = { grant_type : string ; scope : Scopes . t list ; code : string ; client_id : string ; client_secret : string option ; redirect_uri : Uri . t ; } |
let make ( ~ client : Client . t ) ~ grant_type ~ scope ~ redirect_uri ~ code = { grant_type ; scope ; code ; client_id = client . id ; client_secret = client . secret ; redirect_uri ; } |
let to_body_string t = [ ( " grant_type " , [ t . grant_type ] ) ; ( " scope " , [ Scopes . to_scope_parameter t . scope ] ) ; ( " code " , [ t . code ] ) ; ( " client_id " , [ t . client_id ] ) ; ( " client_secret " , [ t . client_secret |> ROpt . get_or ~ default " : secret " ] ) ; ( " redirect_uri " , [ t . redirect... |
let of_body_string body = let query = Uri . query_of_encoded body |> Uri . with_query Uri . empty in let gt = Uri . get_query_param query " grant_type " in let s = Uri . get_query_param query " scope " in let c = Uri . get_query_param query " code " in let ci = Uri . get_query_param query " client_id " in let client_se... |
type t = { token_type : token_type ; scope : Scopes . t list ; expires_in : int option ; access_token : string option ; refresh_token : string option ; id_token : string option ; } |
let make ( ? token_type = Bearer ) ( ? scope = [ ] ) ? expires_in ? access_token ? refresh_token ? id_token ( ) = { token_type ; scope ; expires_in ; access_token ; refresh_token ; id_token } |
let of_yojson json = try let module Json = Yojson . Safe . Util in let scope = match Json . member " scope " json with | ` Null -> [ ] | ` String scope -> Scopes . of_scope_parameter scope | ` List json -> List . map Json . to_string json |> List . map Scopes . of_string | json -> raise ( Json . Type_error ( " scope : ... |
let of_query query = let scope = let qp = Uri . get_query_param query " scope " in Option . value ~ default [ ] : ( Option . map Scopes . of_scope_parameter qp ) in { token_type = Bearer ; scope ; expires_in = Uri . get_query_param query " expires_in " |> Option . map int_of_string ; access_token = Uri . get_query_para... |
let of_string str = Yojson . Safe . from_string str |> of_yojson |
let validate ? clock_tolerance ? nonce ~ jwks ( ~ client : Client . t ) ( ~ discovery : Discover . t ) t = match Jose . Jwt . of_string ( Option . get t . id_token ) with | Ok jwt -> ( if jwt . header . alg = ` None then IDToken . validate ? clock_tolerance ? nonce ~ client ~ issuer : discovery . issuer jwt |> Result .... |
let to_yojson { scope ; expires_in ; access_token ; refresh_token ; id_token ; _ } = let or_null = Option . value ~ default ` : Null in let json_str = Option . map ( fun x -> ` String x ) in ` Assoc [ ( " scope " , match scope with | [ ] -> ` Null | _ -> ` String ( Scopes . to_scope_parameter scope ) ) ; ( " token_type... |
let show input = Eml . Location . reset ( ) ; let underlying = Stream . of_string input in let input_stream = Eml . Location . stream ( fun ( ) -> try Some ( Stream . next underlying ) with _ -> None ) in try input_stream |> Eml . Tokenizer . scan |> List . map Eml . Token . show |> List . iter print_endline with Failu... |
module type TokenKindSig = sig type kind val next : Loc . source -> Lexing . lexbuf -> kind token val kindStr : kind -> string val tokenStr : kind token -> string val isEOF : kind -> bool val getEOF : kind end |
module TokenStream ( S : TokenKindSig ) = struct type stream = { lexbuf : Lexing . lexbuf ; mutable has_errors : bool ; mutable errors : Error . t list ; mutable peeked : S . kind token ; mutable prev : S . kind token ; source : Loc . source } let backup ( s : stream ) = let lexbuf = Lexing . { refill_buff = s . lexbuf... |
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 ] ) ; datatypeparams = None ; comment = None... |
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 = [ ] ; datatypeparams = Some [ tunit ] ; comment... |
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 ^ " . mli " ) let locate_stretches = ... |
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_ITEM of ( string * Location . t * s... |
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 ) : Indent . expectation option = Indent . check_position column ... |
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 ( Tok ) ( State ) ( Expect ) ( Semantic ) (... |
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_locked ) token_locked ) token_locked |> Typ . tran... |
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 | TString s -> ` String s | TDate f -> ` Float f | TAr... |
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 | ` List l -> dec . D . accept_list 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 " -> Ok ` Incubate | " active " -> Ok ` Active | " sustain... |
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 metadata . lifecycle with | Ok x -> x ... |
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 . string v . description pp_lifecycle v . lifecycle |
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 " ( ) in let _ = tool_new_file # set_ic... |
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 -> unit ) option ; } |
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 . . . " , ( fun _ -> editor # dialog_file_open ( ) ) , None ; 300 , ` ... |
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_callback_menu ; } ) ( specs ~ browser ) in items , fun tag... |
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 ( GMisc . image ~ stock ~ icon_size ` : SMALL_TOOLBAR ( ... |
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 ; item . check # connect # toggled ~ callback : be... |
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 false ; let arrow = GMisc . arrow ~ kind... |
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 edge_count dep ) then Hashtbl . add edge_coun... |
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 . create ( ) in Hashtbl . iter ( fun target count -> i... |
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 -> ( ) ) ; let lst = sort ! lst in let files = Hashtbl ... |
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 ] ; value warning_verbose = ref True ; value rec get_token_li... |
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 " | " . mpg " | " . mpeg " | " . mov " | " . 3gp " -> Some ` Movie | _ -> None |
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 . map ( fun x -> ( x # title , x # id ) ) photos... |
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 pset -> pset # title = photoset ) psets |> Option . fma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.