text stringlengths 0 601k |
|---|
module Core_over_monad ( M : Preface_specs . MONAD ) ( Req : Preface_specs . Traversable . CORE with type ' a t = ' a M . t ) = Core ( Req ) |
module Operation ( C : Preface_specs . Traversable . CORE ) = struct type ' a t = ' a C . t type ' a iter = ' a C . iter let sequence x = C . traverse id x end |
module Via ( C : Preface_specs . Traversable . CORE ) ( O : Preface_specs . Traversable . OPERATION with type ' a t = ' a C . t and type ' a iter = ' a C . iter ) = struct include C include O end |
module Over_applicative ( A : Preface_specs . APPLICATIVE ) ( Req : Preface_specs . Traversable . WITH_TRAVERSE with type ' a t = ' a A . t ) = struct module Core = Core_over_applicative ( A ) ( Req ) module Operation = Operation ( Core ) include Core include Operation end |
module Over_monad ( M : Preface_specs . MONAD ) ( Req : Preface_specs . Traversable . WITH_TRAVERSE with type ' a t = ' a M . t ) = struct module Core = Core_over_monad ( M ) ( Req ) module Operation = Operation ( Core ) include Core include Operation end |
module Join_with_monad ( I : Preface_specs . MONAD ) ( T : functor ( M : Preface_specs . MONAD ) -> Preface_specs . TRAVERSABLE with type ' a t = ' a M . t and type ' a iter = ' a I . t ) = struct module Traversable = T include I end |
module Join_with_applicative ( I : Preface_specs . APPLICATIVE ) ( T : functor ( A : Preface_specs . APPLICATIVE ) -> Preface_specs . TRAVERSABLE with type ' a t = ' a A . t and type ' a iter = ' a I . t ) = struct module Traversable = T include I end |
type ctx = { map_loc : source_position * source_position -> Result_structure . loc ; fragments : ( string , Graphql_ast . fragment ) Hashtbl . t ; schema : Schema . t ; errors : ( Result_structure . loc * string ) list ref ; warnings : ( Result_structure . loc * string ) list ref ; type_stack : Schema . type_meta optio... |
module type VisitorSig = sig type t val make_self : unit -> t val enter_document : t -> ctx -> document -> unit val exit_document : t -> ctx -> document -> unit val enter_operation_definition : t -> ctx -> operation spanning -> unit val exit_operation_definition : t -> ctx -> operation spanning -> unit val enter_fragme... |
module AbstractVisitor = struct let enter_document _self _ctx _ = ( ) let exit_document _self _ctx _ = ( ) let enter_operation_definition _self _ctx _ = ( ) let exit_operation_definition _self _ctx _ = ( ) let enter_fragment_definition _self _ctx _ = ( ) let exit_fragment_definition _self _ctx _ = ( ) let enter_variabl... |
module Context = struct let push_type ctx type_ref = { ctx with type_stack = Option . flat_map ( fun type_ref -> Schema . lookup_type ctx . schema ( Schema . innermost_name type_ref ) ) type_ref :: ctx . type_stack ; type_literal_stack = type_ref :: ctx . type_literal_stack ; } let push_input_type ctx type_ref = { ctx ... |
let rec as_schema_type_ref = function | Tr_named { item ; _ } -> Schema . Named item | Tr_list { item ; _ } -> Schema . List ( as_schema_type_ref item ) | Tr_non_null_named { item ; _ } -> Schema . NonNull ( Schema . Named item ) | Tr_non_null_list { item ; _ } -> Schema . NonNull ( Schema . List ( as_schema_type_ref i... |
module Visitor ( V : VisitorSig ) = struct let enter_input_value self ctx value = match value . item with | Iv_null -> V . enter_null_value self ctx ( Source_pos . replace value ( ) ) | Iv_int i -> V . enter_int_value self ctx ( Source_pos . replace value i ) | Iv_float f -> V . enter_float_value self ctx ( Source_pos ... |
let find_fragments doc = let open Graphql_ast in let open Source_pos in let lookup = Hashtbl . create 1 in let ( ) = List . iter ( function | Fragment fragment -> Hashtbl . add lookup fragment . item . fg_name . item fragment . item | _ -> ( ) ) doc in lookup |
let make_context config document = { map_loc = config . Generator_utils . map_loc ; fragments = find_fragments document ; schema = config . Generator_utils . schema ; errors = ref [ ] ; warnings = ref [ ] ; type_stack = [ ] ; type_literal_stack = [ ] ; input_type_stack = [ ] ; input_type_literal_stack = [ ] ; parent_ty... |
module type G = sig val is_directed : bool type t module V : Sig . COMPARABLE val iter_vertex : ( V . t -> unit ) -> t -> unit val fold_vertex : ( V . t -> ' a -> ' a ) -> t -> ' a -> ' a val iter_succ : ( V . t -> unit ) -> t -> V . t -> unit val fold_succ : ( V . t -> ' a -> ' a ) -> t -> V . t -> ' a -> ' a end |
module Dfs ( G : G ) = struct module H = Hashtbl . Make ( G . V ) let fold f i g = let h = H . create 97 in let s = Stack . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Stack . push v s end in let rec loop acc = if not ( Stack . is_empty s ) then let v = Stack . pop s in let ns = f v a... |
module Bfs ( G : G ) = struct module H = Hashtbl . Make ( G . V ) let fold f i ( g : G . t ) = let h = H . create 97 in let q = Queue . create ( ) in let push v = if not ( H . mem h v ) then begin H . add h v ( ) ; Queue . add v q end in let rec loop s = if not ( Queue . is_empty q ) then let v = Queue . pop q in let n... |
module type GM = sig type t module V : sig type t end val iter_vertex : ( V . t -> unit ) -> t -> unit val iter_succ : ( V . t -> unit ) -> t -> V . t -> unit module Mark : sig val clear : t -> unit val get : V . t -> int val set : V . t -> int -> unit end end |
module Mark ( G : GM ) = struct let dfs g = G . Mark . clear g ; let n = ref 0 in let rec visit v = if G . Mark . get v = 0 then begin incr n ; G . Mark . set v ! n ; G . iter_succ visit g v end in G . iter_vertex visit g let has_cycle g = G . Mark . clear g ; let rec visit v = G . Mark . set v 1 ; G . iter_succ ( fun ... |
object ( self ) method virtual record : string -> ( string * ' res ) list -> ' res method virtual constr : string -> ( string * ' res ) list -> ' res method virtual tuple : ( string * ' res ) list -> ' res method virtual bool : bool -> ' res method virtual char : char -> ' res method virtual int : int -> ' res method v... |
object ( self ) method virtual tuple : ( string * ( ' res , string ) result ) list -> ( ' res , string ) result method virtual option : ' a . ( ' a -> ' a -> ( ' res , string ) result ) -> ' a option -> ' a option -> ( ' res , string ) result method virtual bool : bool -> bool -> ( ' res , string ) result method virtua... |
let src = Logs . Src . create " git . traverse " ~ doc " : logs git ' s traverse event " |
module Log = ( val Logs . src_log src : Logs . LOG ) |
module type STORE = sig module Hash : S . HASH module Value : Value . S with type hash = Hash . t type t val root : t -> Fpath . t val read_exn : t -> Hash . t -> Value . t Lwt . t val is_shallowed : t -> Hash . t -> bool Lwt . t end |
module Make ( Store : STORE ) = struct let fold t ( f : ' acc -> ? name : Fpath . t -> length : int64 -> Store . Hash . t -> Store . Value . t -> ' acc Lwt . t ) ~ path acc hash = let names = Hashtbl . create 0x100 in let open Lwt . Infix in let rec walk close rest queue acc = match rest with | [ ] -> ( match Queue . p... |
type queue_elem = | Q_symbol of Symbol . t | Q_set_of_closures_id of Set_of_closures_id . t | Q_export_id of Export_id . t |
type symbols_to_export = { symbols : Symbol . Set . t ; export_ids : Export_id . Set . t ; set_of_closure_ids : Set_of_closures_id . Set . t ; set_of_closure_ids_keep_declaration : Set_of_closures_id . Set . t ; relevant_imported_closure_ids : Closure_id . Set . t ; relevant_local_closure_ids : Closure_id . Set . t ; r... |
let traverse ( ~ sets_of_closures_map : Flambda . set_of_closures Set_of_closures_id . Map . t ) ( ~ closure_id_to_set_of_closures_id : Set_of_closures_id . t Closure_id . Map . t ) ( ~ function_declarations_map : A . function_declarations Set_of_closures_id . Map . t ) ( ~ values : Export_info . descr Export_id . Map ... |
let extra_remotes = list ( getenv_default " EXTRA_REMOTES " ) " " |
let pins = list ( getenv_default " PINS " ) " " |
let dir = getenv_default " SRC_DIR " " . " |
let add_remote = let layer = ref 0 in fun remote -> ?|~ " opam remote add extra % d % s " ! layer remote ; incr layer |
let pin pin = match pair pin with | ( pkg , None ) None -> . ?| " opam pin add % s -- dev - repo - n " pkg | ( pkg , Some url ) url -> . ?| " opam pin add % s % s - n " pkg url ; ; |
type ' a tree = Tree of ' a * ' a tree list |
let mkt x ts = Tree ( x , ts ) |
let rec map f ( Tree ( info , children ) ) = Tree ( f info , List . map ( map f ) children ) |
let string_of_tree t = let buf = Buffer . create 16 in let rec to_string indent = let child_to_string continue_indentation mark x = Buffer . add_char buf ' \ n ' ; Buffer . add_string buf indent ; Buffer . add_string buf mark ; to_string ( indent ^ continue_indentation ) x in let rec children_to_string = function | [ x... |
let asy_of_tree t = let buf = Buffer . create 256 in let rec go root k ( Tree ( x , ts ) ) = let name = if root = " " then " node " else root ^ " _ " ^ string_of_int k in Buffer . add_string buf ( Printf . sprintf " TreeNode % s = nodeGM ( % s " \% s " \% s ) ; \ n " name ( if root = " " then " " else root ^ " , " ) x ... |
let dot_of_tree name t = let buf = Buffer . create 256 in let rec go name ( Tree ( x , ts ) ) = Buffer . add_string buf ( Printf . sprintf " % s [ label " =\% s " ] ; \\ n " name x ) ; ignore ( List . fold_left ( fun n t -> let name ' = name ^ " _ " ^ string_of_int n in go name ' t ; Buffer . add_string buf ( Printf . ... |
let str_replace c1 c2 str = try let i = String . index str c1 in let s = Bytes . of_string str in Bytes . set s i c2 ; Bytes . to_string s with Not_found -> str |
let box_node x = Box . frame ( Box . line ( str_replace ' ' : ' \ n ' x ) ) |
let rec box_of_tree = function | Tree ( x , [ ] ) -> box_node x | Tree ( x , ts ) -> Box . connect ( box_node x ) ( List . map box_of_tree ts ) |
module type ATOM = sig type t val t : t Irmin . Type . t val compare : t -> t -> int val to_string : t -> string val of_string : string -> t end |
module Make ( Atom : ATOM ) = struct type atom = Atom . t type node = { l : t ; v : atom ; r : t } and t = | N | B of node type dir = L | R type path = dir list let blank = N let rec insert t path x = match ( path , t ) with | ( [ ] , N ) -> B { l = N ; v = x ; r = N } | ( L :: path ' , B { l = lt ; v = y ; r = rt } ) ... |
let select_sandbox_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " collection - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " collection - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ... |
let terminal_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " terminal - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " terminal - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " ... |
let items = [ select_sandbox_item ; terminal_item ] |
let getTreeItem ~ element = ` Value element |
let getChildren ? element ( ) = match element with | None -> ` Value ( Some items ) | Some _ -> ` Value ( Some [ ] ) |
let register extension = let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Vscode . TreeItem ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Vscode . TreeItem ) ~ viewId " : ocaml - commands " ~ ... |
let discord_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " discord - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " discord - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : C... |
let discuss_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " chat - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " chat - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Ask a q... |
let github_item = let icon = ` LightDark Vscode . TreeItem . LightDarkIcon . { light = ` String ( Path . asset " github - light . svg " |> Path . to_string ) ; dark = ` String ( Path . asset " github - dark . svg " |> Path . to_string ) } in let label = ` TreeItemLabel ( Vscode . TreeItemLabel . create ~ label " : Open... |
let items = [ discord_item ; discuss_item ; github_item ] |
let getTreeItem ~ element = ` Value element |
let getChildren ? element ( ) = match element with | None -> ` Value ( Some items ) | Some _ -> ` Value ( Some [ ] ) |
let register extension = let module TreeDataProvider = Vscode . TreeDataProvider . Make ( Vscode . TreeItem ) in let treeDataProvider = TreeDataProvider . create ~ getTreeItem ~ getChildren ( ) in let disposable = Vscode . Window . registerTreeDataProvider ( module Vscode . TreeItem ) ~ viewId " : ocaml - help " ~ tree... |
module Dependency = struct type t = Sandbox . Package . t let t_of_js : Ojs . t -> t = Stdlib . Obj . magic let t_to_js : t -> Ojs . t = Stdlib . Obj . magic let label t = Sandbox . Package . name t let description t = Promise . return ( Some ( Sandbox . Package . version t ) ) let tooltip t = Sandbox . Package . synop... |
module Command = struct let _open_documentation = let handler ( _ : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in let open Promise . Syntax in let doc = Sandbox . Package . documentation dep in match doc with | None -> Promise . re... |
let getTreeItem ~ element = ` Promise ( Dependency . to_treeitem element ) |
let getChildren ~ instance ? element ( ) = let sandbox = Extension_instance . sandbox instance in match element with | Some element -> ` Promise ( Dependency . get_dependencies element ) | None -> let open Promise . Syntax in let items = let + packages = Sandbox . root_packages sandbox in match packages with | Ok packa... |
let register extension instance = let getChildren = getChildren ~ instance in let module EventEmitter = Vscode . EventEmitter . Make ( Interop . Js . Or_undefined ( Dependency ) ) in let event_emitter = EventEmitter . make ( ) in let event = EventEmitter . event event_emitter in let module TreeDataProvider = Vscode . T... |
module Dependency = struct type t = | Package : Opam . Package . t -> t | Switch : Opam . t * Opam . Switch . t -> t let equals_opam_sandbox t sandbox = match ( t , sandbox ) with | Switch ( opam , switch ) , Sandbox . Opam ( opam_ , switch_ ) -> Opam . equal opam opam_ && Opam . Switch . equal switch switch_ | _ -> fa... |
module Command = struct let _remove_switch = let handler ( _ : Extension_instance . t ) ~ args = let ( _ : unit Promise . t ) = let arg = List . hd_exn args in let dep = Dependency . t_of_js arg in match dep with | Package _ -> Promise . return @@ show_message ` Warn " The selected item is not an opam switch . " | Swit... |
let getTreeItem instance ~ element = ` Promise ( Dependency . to_treeitem instance element ) |
let getChildren ? opam ? element ( ) = match ( opam , element ) with | None , _ -> ` Value None | Some _ , Some element -> ` Promise ( Dependency . get_dependencies element ) | Some opam , None -> let open Promise . Syntax in let items = let + switches = Opam . switch_list opam in let items = List . map ~ f ( : fun swi... |
let register extension instance = let ( _ : unit Promise . t ) = let open Promise . Syntax in let + opam = Opam . make ( ) in let getChildren = getChildren ? opam in let getTreeItem = getTreeItem instance in let module EventEmitter = Vscode . EventEmitter . Make ( Interop . Js . Or_undefined ( Dependency ) ) in let eve... |
module Filesys = struct let join_path path = if path = [ " " ] then " " / else String . concat " " / path let split_re = Str . regexp " " / let split_path s = Str . split split_re s let list path = let path_name = join_path path in let d = Unix . opendir path_name in let l = ref [ ] in try while true do l := e :: ! l d... |
module Filetree_dlg = struct open Lx_tree . Types ; ; open Tk ; ; open Widget ; ; type node = { path : string list ; } let some = function Some x -> x | None -> assert false let selected = ref [ ] let name_tv = lazy ( Textvariable . create ( ) ) let listbox = ref None let dir_label = ref None let ok_button = ref None l... |
module S = struct type t = string let compare = compare end ; ; |
module StringSet = Set . Make ( S ) ; ; |
type filetype = Regular | Directory | Absent ; ; |
type node = { path : string list ; name : string ; mutable is_dir : bool ; mutable selected : bool ; mutable realtype : filetype ; } ; ; |
type file_tree = node tree ; ; |
type state = { mutable current_directory : string ; mutable list_file : string ; mutable tree_widget : node tree_widget option ; mutable info_widget : label widget option ; mutable dir_context_menu : menu widget option ; mutable dir_context_suffix_menu : menu widget option ; mutable dir_context_unsuffix_menu : menu wid... |
let dummy_tree = { node = { path = [ ] ; children = [ ] ; show = false ; scanned = false ; interactive = false ; } ; ; |
let rescan_node tw tree = let files = Filesys . list tree . node . path in let missing_files = List . map ( fun child -> child . node . name ) ( List . filter ) in let all_files = List . sort compare ( files @ missing_files ) in let old_children = tree . children in let new_children = List . map ( fun filename -> ) all... |
let rec selected_files_exist tree = tree . node . selected || selected_files_exist_in_children tree List . exists selected_files_exist tree . children ; ; |
let rec expand ( ? all = false ) tw tree = let show = tree . node . is_dir && ( all || selected_files_exist_in_children tree ) in tree . show <- tree . show || show ; if show then rescan_node tw tree ; List . iter ( fun child -> expand ~ all tw child ) tree . children ; ; |
let rec collapse tw tree = tree . show <- false ; List . iter ( fun child -> collapse tw child ) tree . children ; ; |
let suffix_re = Str . regexp " . [ . ] " ; ; \\^+$ |
let rec find_suffixes ( ? recursive = false ) tw tree = assert ( tree . node . is_dir ) ; rescan_node tw tree ; tree . show <- true ; let files = List . map ( fun ch -> ch . node . name ) tree . children in let suff = List . filter ( fun s -> ) ( List . map ) in let suff_set = ref ( StringSet . empty ) in List . iter (... |
let rec select_suffixes ( ? recursive = false ) ( ? unselect = false ) suffix tree = prerr_endline " select_suffixes " ; List . iter ( fun child -> let child_suff = in if child_suff = suffix && not ( child . node . is_dir ) then if recursive && child . node . is_dir then ) tree . children ; ; |
let rec select_all ( ? recursive = false ) ( ? unselect = false ) tree = prerr_endline " select_all " ; List . iter ( fun child -> if not ( child . node . is_dir ) then if recursive && child . node . is_dir then ) tree . children ; ; |
let set_suffix_menu ? unselect tw menu tree = Menu . delete menu ~ first ( ` : Num 0 ) ~ last ` : End ; let suffixes = find_suffixes tw tree in StringSet . iter ( fun s -> Menu . add_command ~ label : s ~ command ( : fun ( ) -> ) suffixes ; ; |
let node_action st tw tree ev evinfo = match ( ev : Lx_spots . supported_event ) with ` ButtonPress -> ) end | ` Enter -> end | ` Leave -> end | _ -> ( ) ; ; |
let display_node st = let node_action_st = node_action st in fun tw tree -> let node = tree . node in let image = if node . is_dir then st . directory_xpm else else in let foreground = match ( node . realtype , node . is_dir ) with in let events = [ ` ButtonPress ; ` Enter ; ` Leave ] in Lx_tree . display_text ~ image ... |
let neutral_frame wdg = Frame . create ~ highlightthickness : 0 ~ borderwidth : 0 wdg ; ; |
let save st = let rec write_file file path tree = let full_name = if path = " " then tree . node . name else in if not tree . node . is_dir && tree . node . selected then begin output_string file full_name ; output_string file " \ n " ; end ; List . iter ( fun child -> write_file file full_name child ) tree . children ... |
let q_save st = if st . modified then begin let choice = Dialog . create ~ parent : st . topwdg ~ title " : Save " ? ~ message " : The current tree is modified . Save it to disk " ? ~ buttons [ : " Yes " ; " No " ; " Cancel " ] ( ) in match choice with | 1 -> true | 2 -> false end else true ; ; |
let drop st = st . list_file <- " " ; st . modified <- false ; Frame . configure ~ width : 400 ~ height : 600 st . workframe ; List . iter destroy ( Winfo . children st . workframe ) ; st . tree_widget <- None ; ; |
let create_work_tree st top_node = let tree_frame = neutral_frame st . workframe in let info_frame = neutral_frame st . workframe in let sbar = Scrollbar . create ~ orient ` : Vertical tree_frame in let info_label = Label . create ~ highlightthickness : 0 ~ borderwidth : 0 ~ justify ` : Left ~ text " : " info_frame in ... |
let file_new st ( ) = let enable_ok filename = not ( Sys . file_exists filename ) in if q_save st then begin match Filetree_dlg . open_dialog ~ title " : New tree " ~ enable_ok st . topwdg with | None -> end ; ; |
let strip_ws_re = Str . regexp " [ ^ \ r \ n \ t ] ( . ) [ *\\*\\ \ r \ n \ t ] " ; ; *$ |
let strip_ws s = if Str . string_match strip_ws_re s 0 then Str . matched_group 1 s else assert false ; ; |
let file_open st ( ) = let rec enter_path path node = match path with | [ ] -> in let rec read_file file initial_node = let line = strip_ws ( input_line file ) in if line = " " then read_file file initial_node else begin let path = Filesys . split_path line in enter_path path initial_node ; read_file file initial_node ... |
let file_save st ( ) = save st ; ignore ( Dialog . create ~ parent : st . topwdg ~ title " : Saved " ~ message " : Tree saved . " ; ; |
let file_quit st ( ) = if q_save st then destroy st . topwdg ; ; |
let view_expand ? all st ( ) = match st . tree_widget with Some tw -> | None -> ( ) ; ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.