text stringlengths 0 601k |
|---|
let compare compareFirst compareSecond compareThird ( a , b , c ) c ( a ' , b ' , c ' ) c ' = match compareFirst a a ' with | 0 -> ( match compareSecond b b ' with 0 -> compareThird c c ' | result -> result ) result | result -> result |
module type TABLES = sig type token val token2terminal : token -> int val error_terminal : int val token2value : token -> Obj . t val default_reduction : PackedIntArray . t val error : int * string val action : PackedIntArray . t * PackedIntArray . t val lhs : PackedIntArray . t val goto : PackedIntArray . t * PackedIn... |
module MakeEngineTable ( T : TableFormat . TABLES ) = struct type state = int let number s = s type token = T . token type terminal = int type nonterminal = int type semantic_value = Obj . t let token2terminal = T . token2terminal let token2value = T . token2value let error_terminal = T . error_terminal let error_value... |
let fatal_error s = raise ( Compiler_Error s ) |
type mltype = Unit | Int | Float | Bool | Char | String | List of mltype | Product of mltype list | Record of ( string * mltype ) list | UserDefined of string | Subtype of string * string | Function of mltype | As of mltype * string |
type template = StringArg of string | TypeArg of string * mltype | ListArg of template list | OptionalArgs of string * template list * template list |
type component_type = Constructor | Command | External |
type fullcomponent = { component : component_type ; ml_name : string ; var_name : string ; template : template ; result : mltype ; safe : bool } |
let sort_components = List . sort ~ cmp ( : fun c1 c2 -> compare c1 . ml_name c2 . ml_name ) |
type component = Full of fullcomponent | Abbrev of string |
type type_def = { parser_arity : parser_arity ; mutable constructors : fullcomponent list ; mutable subtypes : ( string * fullcomponent list ) list ; mutable requires_widget_context : bool ; mutable variant : bool } |
type module_type = Widget | Family |
type module_def = { module_type : module_type ; commands : fullcomponent list ; externals : fullcomponent list } |
let types_table = ( Hashtbl . create 37 : ( string , type_def ) Hashtbl . t ) |
let types_external = ref ( [ ] : ( string * parser_arity ) list ) |
let types_order = ( Tsort . create ( ) : string Tsort . porder ) |
let types_returned = ref ( [ ] : string list ) |
let function_table = ref ( [ ] : fullcomponent list ) |
let module_table = ( Hashtbl . create 37 : ( string , module_def ) Hashtbl . t ) |
let rec getvarname ml_name temp = let offhypben s = let s = String . copy s in if ( try String . sub s ~ pos : 0 ~ len : 1 with _ -> " " ) = " " - then String . sub s ~ pos : 1 ~ len ( : String . length s - 1 ) else s and makecapital s = begin try let cd = s . [ 0 ] in if cd >= ' a ' && cd <= ' z ' then s . [ 0 ] <- Ch... |
let new_type typname arity = Tsort . add_element types_order typname ; let typdef = { parser_arity = arity ; constructors = [ ] ; subtypes = [ ] ; requires_widget_context = false ; variant = false } in Hashtbl . add types_table typname typdef ; typdef |
let is_subtyped s = s = " widget " || try let typdef = Hashtbl . find types_table s in typdef . subtypes <> [ ] with Not_found -> false |
let requires_widget_context s = try ( Hashtbl . find types_table s ) . requires_widget_context with Not_found -> false |
let declared_type_parser_arity s = try ( Hashtbl . find types_table s ) . parser_arity with Not_found -> try List . assoc s ! types_external with Not_found -> prerr_string " Type " ; prerr_string s ; prerr_string " is undeclared external or undefined \ n " ; prerr_string ( " Assuming cTKtoCAML " ^ s " ^ : string -> " ^... |
let rec type_parser_arity = function Unit -> OneToken | Int -> OneToken | Float -> OneToken | Bool -> OneToken | Char -> OneToken | String -> OneToken | List _ -> MultipleToken | Product _ -> MultipleToken | Record _ -> MultipleToken | UserDefined s -> declared_type_parser_arity s | Subtype ( s , _ ) -> declared_type_p... |
let enter_external_type s v = types_external := ( s , v ) ::! types_external |
let rec enter_argtype = function Unit | Int | Float | Bool | Char | String -> ( ) | List ty -> enter_argtype ty | Product tyl -> List . iter ~ f : enter_argtype tyl | Record tyl -> List . iter tyl ~ f ( : fun ( l , t ) -> enter_argtype t ) | UserDefined s -> Tsort . add_element types_order s | Subtype ( s , _ ) -> Tsor... |
let rec enter_template_types = function StringArg _ -> ( ) | TypeArg ( l , t ) -> enter_argtype t | ListArg l -> List . iter ~ f : enter_template_types l | OptionalArgs ( _ , tl , _ ) -> List . iter ~ f : enter_template_types tl |
let rec add_dependancies s = function List ty -> add_dependancies s ty | Product tyl -> List . iter ~ f ( : add_dependancies s ) tyl | Subtype ( s ' , _ ) -> if s <> s ' then Tsort . add_relation types_order ( s ' , s ) | UserDefined s ' -> if s <> s ' then Tsort . add_relation types_order ( s ' , s ) | Function ty -> ... |
let rec add_template_dependancies s = function StringArg _ -> ( ) | TypeArg ( l , t ) -> add_dependancies s t | ListArg l -> List . iter ~ f ( : add_template_dependancies s ) l | OptionalArgs ( _ , tl , _ ) -> List . iter ~ f ( : add_template_dependancies s ) tl |
let rec has_callback = function StringArg _ -> false | TypeArg ( l , Function _ ) -> true | TypeArg _ -> false | ListArg l -> List . exists ~ f : has_callback l | OptionalArgs ( _ , tl , _ ) -> List . exists ~ f : has_callback tl |
let really_add ty = if List . mem ty ! types_returned then ( ) else types_returned := ty :: ! types_returned |
let rec add_return_type = function Unit -> ( ) | Int -> ( ) | Float -> ( ) | Bool -> ( ) | Char -> ( ) | String -> ( ) | List ty -> add_return_type ty | Product tyl -> List . iter ~ f : add_return_type tyl | Record tyl -> List . iter tyl ~ f ( : fun ( l , t ) -> add_return_type t ) | UserDefined s -> really_add s | Sub... |
let enter_component_types { template = t ; result = r } = add_return_type r ; enter_argtype r ; enter_template_types t |
let rec check_duplicate_constr allowed c = function [ ] -> false | c ' :: rest -> if c . ml_name = c ' . ml_name then if allowed then if c . template = c ' . template then true else raise ( Duplicate_Definition ( " constructor " , c . ml_name ) ) else raise ( Duplicate_Definition ( " constructor " , c . ml_name ) ) els... |
let rec find_constructor cname = function [ ] -> raise ( Invalid_implicit_constructor cname ) | c :: l -> if c . ml_name = cname then c else find_constructor cname l |
let enter_type typname ( ? variant = false ) arity constructors = if Hashtbl . mem types_table typname then raise ( Duplicate_Definition ( " type " , typname ) ) else let typdef = new_type typname arity in if variant then typdef . variant <- true ; List . iter constructors ~ f : begin fun c -> if not ( check_duplicate_... |
let enter_subtype typ arity subtyp constructors = let typdef = try Hashtbl . find types_table typ with Not_found -> new_type typ arity in if List . mem_assoc subtyp typdef . subtypes then raise ( Duplicate_Definition ( " subtype " , typ " ^ " ^ subtyp ) ) else begin let real_constructors = List . map constructors ~ f :... |
let retrieve_option optname = let optiontyp = try Hashtbl . find types_table " options " with Not_found -> raise ( Invalid_implicit_constructor optname ) in find_constructor optname optiontyp . constructors |
let rec add_sort l obj = match l with [ ] -> [ obj . component , [ obj ] ] | ( s ' , l ) :: rest -> if obj . component = s ' then ( s ' , obj :: l ) :: rest else ( s ' , l ) ( :: add_sort rest obj ) |
let separate_components = List . fold_left ~ f : add_sort ~ init [ ] : |
let enter_widget name components = if Hashtbl . mem module_table name then raise ( Duplicate_Definition ( " widget / module " , name ) ) else let sorted_components = separate_components components in List . iter sorted_components ~ f : begin function Constructor , l -> enter_subtype " options " MultipleToken name ( Lis... |
let enter_function comp = enter_component_types comp ; function_table := comp :: ! function_table |
let enter_module name components = if Hashtbl . mem module_table name then raise ( Duplicate_Definition ( " widget / module " , name ) ) else let sorted_components = separate_components components in List . iter sorted_components ~ f : begin function Constructor , l -> fatal_error " unexpected Constructor " | Command ,... |
module For_testing = struct type cell = { id : Int63 . t ; selected : bool ; view : Vdom . Node . t list } type t = { column_names : Vdom . Node . t list ; cells : cell list ; rows_before : int ; rows_after : int ; num_filtered : int ; num_unfiltered : int } end |
let sort_map_values_by_idx values = if Map . is_empty values then [ ] || else ( let placeholder , _ = Map . max_elt_exn values in let arr = Array . init ( Map . length values ) ~ f ( : fun _ -> Int63 . zero , placeholder , [ ] ) in let i = ref 0 in Map . iteri values ~ f ( : fun ~ key ~ data ( : idx , value ) -> Array ... |
let instantiate_cells ~ assoc remapped = let % sub cells = assoc remapped in return @@ Value . map cells ~ f : sort_map_values_by_idx ; ; |
let set_or_wrap ? key ( ? attrs = [ ] ) ~ classes ~ style = let open Vdom . Node in function | Element e -> Option . value_map key ~ f ( : Element . with_key e ) ~ default : e |> Fn . flip Element . add_style style |> Fn . flip Element . add_classes classes |> Element . map_attrs ~ f ( : fun old_attrs -> Vdom . Attr . ... |
let component ( type key data cmp ) ( ~ comparator : ( key , cmp ) Bonsai . comparator ) ~ row_height ( ~ leaves : Header_tree . leaf list Value . t ) ~ assoc ~ column_widths ( ~ visually_focused : key option Value . t ) ~ on_row_click ( collated : ( key , data ) Collated . t Value . t ) ( remapped : ( key , Int63 . t ... |
let attr_colspan i = match i with | 0 -> Vdom . Attr . style ( Css_gen . display ` None ) | 1 -> Vdom . Attr . empty | i -> Vdom . Attr . create_float " colspan " ( Int . to_float i ) ; ; |
module Acc = struct type t = { level_map : Vdom . Node . t list Int . Map . t ; leaf_index : int } let empty = { level_map = Int . Map . empty ; leaf_index = 0 } let visit_leaf { level_map ; leaf_index } ~ level ~ node = let idx = leaf_index in let leaf_index = leaf_index + 1 in let level_map = Int . Map . add_multi le... |
let rec render_header header ~ level ~ acc ~ set_column_width = let recurse = render_header ~ level ( : level + 1 ) ~ set_column_width in let recurse_no_level_change = render_header ~ level ~ set_column_width in let colspan = attr_colspan ( Header_tree . colspan header ) in match header with | Leaf { visible ; leaf_lab... |
let render_header headers ~ set_column_width = headers |> render_header ~ acc : Acc . empty ~ level : 0 ~ set_column_width |> Acc . finalize ; ; |
let component ( headers : Header_tree . t Value . t ) ~ set_column_width ~ set_header_height = return @@ let % map set_column_width = set_column_width and set_header_height = set_header_height and headers = headers in let rows = render_header headers ~ set_column_width in Vdom . Node . table ~ attr : ( Vdom . Attr . ma... |
module PersonTable = struct type t = { first_name : string ; last_name : string ; phone_number : string ; } let to_string { first_name ; _ } = Printf . sprintf " First Name : % s " first_name let to_bytes { first_name ; last_name ; phone_number } = let fn_len = String . length first_name in let ln_len = String . length... |
module Table = Dbtlk_table . Make ( PersonTable ) |
let next_person = let counter = ref 0 in fun ( ) -> incr counter ; let first_name = Printf . sprintf " Maxime_ % 010i " ! counter in let last_name = Printf . sprintf " Ransan_ % 010i " ! counter in let phone_number = " 9179298071 " in PersonTable . { first_name ; last_name ; phone_number } |
type db = { db : Table . t ; fd : Unix . file_descr ; } |
let open_empty_db file_name = let fd = Unix . openfile file_name [ Unix . O_RDWR ; Unix . O_CREAT ] 0o640 in let db , write_ops = Table . make_empty ( ) in Btree_unix . do_write_ops fd write_ops ; { db ; fd ; } |
let open_from_file file_name = let fd = Unix . openfile file_name [ Unix . O_RDWR ; Unix . O_CREAT ] 0o640 in let db = Btree_unix . do_res fd @@ Table . make_from_file ( ) in { db ; fd ; } |
let insert { db ; fd } record = Table . insert db record |> Btree_unix . do_res fd |> Btree_unix . do_write_ops fd |
let close { fd ; _ } = Unix . close fd |
let to_string { db ; _ } = Table . to_string db |
let debug { db ; fd } = Btree_unix . do_res fd ( Table . debug db ) |
let ( ) = let t0 = Unix . gettimeofday ( ) in let n = 200_000 in let rec aux db = function | 0 -> close db ; | i -> let db = if i mod 1_000 = 0 then begin close db ; open_from_file " db . data " end else db in insert db ( next_person ( ) ) ; aux db ( i - 1 ) in aux ( open_empty_db " db . data " ) n ; let t1 = Unix . ge... |
module Make ( F : FINITE_TYPE ) ( M : MINIMAL_IMPERATIVE_MAPS with type key = F . t ) type key = M . key let tabulate ( f : key -> ' a ) : key -> ' a = let table = M . create ( ) in F . foreach ( fun x -> M . add x ( f x ) table ) ; fun x -> try M . find x table with Not_found -> let msg = Printf . sprintf " \ n Fix . ... |
module ForOrderedType ( F : FINITE_TYPE ) ( T : OrderedType with type t = F . t ) = Make ( F ) ( Glue . PersistentMapsToImperativeMaps ( Map . Make ( T ) ) ) |
module ForHashedType ( F : FINITE_TYPE ) ( T : HashedType with type t = F . t ) = Make ( F ) ( Glue . HashTablesAsImperativeMaps ( T ) ) |
module ForType ( F : FINITE_TYPE ) = ForHashedType ( F ) ( Glue . TrivialHashedType ( F ) ) |
module ForIntSegment ( K : sig val n : int end ) = struct type key = int let tabulate ( f : key -> ' a ) : key -> ' a = let table = Array . init K . n f in fun x -> table . ( x ) end |
module Column = struct module Format = struct type ' a t = { align_right : bool ; header : string ; pad_right : int ; sortable : bool ; width : ' a } [ @@ deriving sexp_of ] let create ( ? align_right = false ) ( ? pad_right = 1 ) ( ? sortable = true ) ~ header ~ width ( ) = { align_right ; pad_right ; sortable ; heade... |
type ( ' record , ' id ) t = { columns : ' record Column . t list ; entries_var : ' record list Buffer_local . t ; id_equal : ' id -> ' id -> bool ; id_of_record : ' record -> ' id ; id_type : ' id Value . Type . t ; major_mode : Major_mode . t } |
let keymap t = Major_mode . keymap ( major_mode t ) |
let tabulated_list_format_var = Buffer_local . Wrap . ( " tabulated - list - format " <: vector Column . Format . Fixed_width . t ) ; ; |
let tabulated_list_sort_key_var = Buffer_local . Wrap . ( " tabulated - list - sort - key " <: nil_or ( tuple string bool ) ) ; ; |
let tabulated_list_init_header = Funcall . Wrap . ( " tabulated - list - init - header " <: nullary @-> return nil ) ; ; |
let tabulated_list_print = Funcall . Wrap . ( " tabulated - list - print " <: bool @-> bool @-> return nil ) ; ; |
let draw ? sort_by t rows = Option . iter sort_by ~ f ( : fun ( sort_header , _ ) -> match List . find t . columns ~ f ( : fun column -> String . equal sort_header column . format . header ) with | None -> raise_s [ % sexp " Unknown header to sort by " , ( sort_header : string ) ] | Some column -> if not column . forma... |
module Tabulated_list_mode = ( val Major_mode . wrap_existing " tabulated - list - mode " [ % here ] ) |
let create major_mode columns ~ id_equal ~ id_type ~ id_of_record = if not ( Major_mode . is_derived major_mode ~ from : Tabulated_list_mode . major_mode ) then raise_s [ % sexp " [ Tabulated_list . create ] called on a major mode not derived from \ [ Tabulated_list . Tabulated_list_mode . major_mode ] . " ] ; let entr... |
let tabulated_list_get_id = Funcall . Wrap . ( " tabulated - list - get - id " <: nullary @-> return ( nil_or value ) ) ; ; |
let get_id_at_point_exn t = Option . map ( tabulated_list_get_id ( ) ) ~ f ( : Value . Type . of_value_exn t . id_type ) ; ; |
let move_point_to_id t id = Point . goto_min ( ) ; let rec loop ( ) = match get_id_at_point_exn t with | None -> raise_s [ % sexp " Could not find row with given id " ] | Some id_at_point -> ( match t . id_equal id id_at_point with | false -> Point . forward_line 1 ; loop ( ) | true -> ( ) ) in loop ( ) ; ; |
let current_buffer_has_entries ( ) = not ( Value . is_nil ( Current_buffer . get_buffer_local Buffer_local . Wrap . ( " tabulated - list - entries " <: value ) ) ) ; ; |
let revert_hook = Hook . Wrap . ( " tabulated - list - revert - hook " <: Normal_hook ) |
let navli ( ) = ReactiveData . RList . empty |
let tab_is_active , set_tab_is_active = React . S . create false |
let tab_was_active = ref false |
let content ( ) = let constraints_div = State_project . on_project_change_async ~ on : tab_is_active ( ) ( React . S . const ( ) ) [ ] ( fun ( manager : Api . concrete_manager ) ( ) -> ( manager # get_constraints_list >|= Result_util . fold ~ ok ( : fun constraints -> List . fold_left ( fun panels ( a , b ) -> let text... |
let parent_hide ( ) = set_tab_is_active false |
let parent_shown ( ) = set_tab_is_active ! tab_was_active |
let onload ( ) = let ( ) = Common . jquery_on " # navconstraints " " hide . bs . tab " ( fun _ -> let ( ) = tab_was_active := false in set_tab_is_active false ) in let ( ) = Common . jquery_on " # navconstraints " " shown . bs . tab " ( fun _ -> let ( ) = tab_was_active := true in set_tab_is_active true ) in ( ) |
let onresize ( ) : unit = ( ) |
let navli ( ) = ReactiveData . RList . empty |
let tab_is_active , set_tab_is_active = React . S . create true |
let tab_was_active = ref true |
let accuracy , set_accuracy = React . S . create ( Some Public_data . Low ) |
let extract_contact_map = function | ` Assoc [ " contact map " , ` Assoc [ " accuracy " , acc ; " map " , contact ] ] -> acc , contact | ` Assoc [ " contact map " , ` Assoc [ " map " , contact ; " accuracy " , acc ] ] -> acc , contact | _ -> failwith " Wrong ugly contact_map extractor " |
let contact_map_text = State_project . on_project_change_async ~ on : tab_is_active None accuracy ( Result_util . error [ ] ) ( fun ( manager : Api . concrete_manager ) acc -> manager # get_contact_map acc >|= Result_util . map ( fun contact_json -> let _ , map_json = extract_contact_map contact_json in Yojson . Basic ... |
let configuration : Widget_export . configuration = { Widget_export . id = export_id ; Widget_export . handlers = [ Widget_export . export_svg ~ svg_div_id : display_id ( ) ; Widget_export . export_png ~ svg_div_id : display_id ( ) ; Widget_export . export_json ~ serialize_json ( : fun ( ) -> Result_util . fold ( React... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.