text stringlengths 0 601k |
|---|
let add_modtype id ty s = { s with modtypes = Ident . Map . add id ty s . modtypes } |
let for_saving s = { s with for_saving = true } |
let loc s x = if s . for_saving && not ! Clflags . keep_locs then Location . none else x |
let remove_loc = let open Ast_mapper in { default_mapper with location = ( fun _this _loc -> Location . none ) } |
let is_not_doc = function | { Parsetree . attr_name = { Location . txt = " ocaml . doc " } ; _ } -> false | { Parsetree . attr_name = { Location . txt = " ocaml . text " } ; _ } -> false | { Parsetree . attr_name = { Location . txt = " doc " } ; _ } -> false | { Parsetree . attr_name = { Location . txt = " text " } ; _... |
let attrs s x = let x = if s . for_saving && not ! Clflags . keep_docs then List . filter is_not_doc x else x in if s . for_saving && not ! Clflags . keep_locs then remove_loc . Ast_mapper . attributes remove_loc x else x |
let rec module_path s path = try Path . Map . find path s . modules with Not_found -> match path with | Pident _ -> path | Pdot ( p , n ) -> Pdot ( module_path s p , n ) | Papply ( p1 , p2 ) -> Papply ( module_path s p1 , module_path s p2 ) |
let modtype_path s = function Pident id as p -> begin try match Ident . Map . find id s . modtypes with | Mty_ident p -> p | _ -> fatal_error " Subst . modtype_path " with Not_found -> p end | Pdot ( p , n ) -> Pdot ( module_path s p , n ) | Papply _ -> fatal_error " Subst . modtype_path " |
let type_path s path = match Path . Map . find path s . types with | Path p -> p | Type_function _ -> assert false | exception Not_found -> match path with | Pident _ -> path | Pdot ( p , n ) -> Pdot ( module_path s p , n ) | Papply _ -> fatal_error " Subst . type_path " |
let type_path s p = match Path . constructor_typath p with | Regular p -> type_path s p | Cstr ( ty_path , cstr ) -> Pdot ( type_path s ty_path , cstr ) | LocalExt _ -> type_path s p | Ext ( p , cstr ) -> Pdot ( module_path s p , cstr ) |
let to_subst_by_type_function s p = match Path . Map . find p s . types with | Path _ -> false | Type_function _ -> true | exception Not_found -> false |
let new_id = ref ( - 1 ) |
let reset_for_saving ( ) = new_id := - 1 |
let newpersty desc = decr new_id ; { desc ; level = generic_level ; scope = Btype . lowest_level ; id = ! new_id } |
let tvar_none = Tvar None |
let tunivar_none = Tunivar None |
let norm = function | Tvar None -> tvar_none | Tunivar None -> tunivar_none | d -> d |
let ctype_apply_env_empty = ref ( fun _ -> assert false ) |
let rec typexp copy_scope s ty = let ty = repr ty in match ty . desc with Tvar _ | Tunivar _ as desc -> if s . for_saving || ty . id < 0 then let ty ' = if s . for_saving then newpersty ( norm desc ) else newty2 ty . level desc in For_copy . save_desc copy_scope ty desc ; ty . desc <- Tsubst ty ' ; ty ' else ty | Tsubs... |
let type_expr s ty = For_copy . with_scope ( fun copy_scope -> typexp copy_scope s ty ) |
let label_declaration copy_scope s l = { ld_id = l . ld_id ; ld_mutable = l . ld_mutable ; ld_type = typexp copy_scope s l . ld_type ; ld_loc = loc s l . ld_loc ; ld_attributes = attrs s l . ld_attributes ; } |
let constructor_arguments copy_scope s = function | Cstr_tuple l -> Cstr_tuple ( List . map ( typexp copy_scope s ) l ) | Cstr_record l -> Cstr_record ( List . map ( label_declaration copy_scope s ) l ) |
let constructor_declaration copy_scope s c = { cd_id = c . cd_id ; cd_args = constructor_arguments copy_scope s c . cd_args ; cd_res = Option . map ( typexp copy_scope s ) c . cd_res ; cd_loc = loc s c . cd_loc ; cd_attributes = attrs s c . cd_attributes ; } |
let type_declaration ' copy_scope s decl = { type_params = List . map ( typexp copy_scope s ) decl . type_params ; type_arity = decl . type_arity ; type_kind = begin match decl . type_kind with Type_abstract -> Type_abstract | Type_variant cstrs -> Type_variant ( List . map ( constructor_declaration copy_scope s ) cstr... |
let type_declaration s decl = For_copy . with_scope ( fun copy_scope -> type_declaration ' copy_scope s decl ) |
let class_signature copy_scope s sign = { csig_self = typexp copy_scope s sign . csig_self ; csig_vars = Vars . map ( function ( m , v , t ) -> ( m , v , typexp copy_scope s t ) ) sign . csig_vars ; csig_concr = sign . csig_concr ; csig_inher = List . map ( fun ( p , tl ) -> ( type_path s p , List . map ( typexp copy_s... |
let rec class_type copy_scope s = function | Cty_constr ( p , tyl , cty ) -> let p ' = type_path s p in let tyl ' = List . map ( typexp copy_scope s ) tyl in let cty ' = class_type copy_scope s cty in Cty_constr ( p ' , tyl ' , cty ' ) | Cty_signature sign -> Cty_signature ( class_signature copy_scope s sign ) | Cty_ar... |
let class_declaration ' copy_scope s decl = { cty_params = List . map ( typexp copy_scope s ) decl . cty_params ; cty_variance = decl . cty_variance ; cty_type = class_type copy_scope s decl . cty_type ; cty_path = type_path s decl . cty_path ; cty_new = begin match decl . cty_new with | None -> None | Some ty -> Some ... |
let class_declaration s decl = For_copy . with_scope ( fun copy_scope -> class_declaration ' copy_scope s decl ) |
let cltype_declaration ' copy_scope s decl = { clty_params = List . map ( typexp copy_scope s ) decl . clty_params ; clty_variance = decl . clty_variance ; clty_type = class_type copy_scope s decl . clty_type ; clty_path = type_path s decl . clty_path ; clty_loc = loc s decl . clty_loc ; clty_attributes = attrs s decl ... |
let cltype_declaration s decl = For_copy . with_scope ( fun copy_scope -> cltype_declaration ' copy_scope s decl ) |
let class_type s cty = For_copy . with_scope ( fun copy_scope -> class_type copy_scope s cty ) |
let value_description ' copy_scope s descr = { val_type = typexp copy_scope s descr . val_type ; val_kind = descr . val_kind ; val_loc = loc s descr . val_loc ; val_attributes = attrs s descr . val_attributes ; } |
let value_description s descr = For_copy . with_scope ( fun copy_scope -> value_description ' copy_scope s descr ) |
let extension_constructor ' copy_scope s ext = { ext_type_path = type_path s ext . ext_type_path ; ext_type_params = List . map ( typexp copy_scope s ) ext . ext_type_params ; ext_args = constructor_arguments copy_scope s ext . ext_args ; ext_ret_type = Option . map ( typexp copy_scope s ) ext . ext_ret_type ; ext_priv... |
let extension_constructor s ext = For_copy . with_scope ( fun copy_scope -> extension_constructor ' copy_scope s ext ) |
type scoping = | Keep | Make_local | Rescope of int |
let rename_bound_idents scoping s sg = let rename = let open Ident in match scoping with | Keep -> ( fun id -> create_scoped ~ scope ( : scope id ) ( name id ) ) | Make_local -> Ident . rename | Rescope scope -> ( fun id -> create_scoped ~ scope ( name id ) ) in let rec rename_bound_idents s sg = function | [ ] -> sg ,... |
let rec modtype scoping s = function Mty_ident p as mty -> begin match p with Pident id -> begin try Ident . Map . find id s . modtypes with Not_found -> mty end | Pdot ( p , n ) -> Mty_ident ( Pdot ( module_path s p , n ) ) | Papply _ -> fatal_error " Subst . modtype " end | Mty_signature sg -> Mty_signature ( signatu... |
let merge_tbls f m1 m2 = Ident . Map . fold ( fun k d accu -> Ident . Map . add k ( f d ) accu ) m1 m2 |
let merge_path_maps f m1 m2 = Path . Map . fold ( fun k d accu -> Path . Map . add k ( f d ) accu ) m1 m2 |
let type_replacement s = function | Path p -> Path ( type_path s p ) | Type_function { params ; body } -> let params = List . map ( type_expr s ) params in let body = type_expr s body in Type_function { params ; body } |
let compose s1 s2 = { types = merge_path_maps ( type_replacement s2 ) s1 . types s2 . types ; modules = merge_path_maps ( module_path s2 ) s1 . modules s2 . modules ; modtypes = merge_tbls ( modtype Keep s2 ) s1 . modtypes s2 . modtypes ; for_saving = s1 . for_saving || s2 . for_saving ; } |
let subst_module_expr_forward = ref ( fun _ -> assert false ) ; ; |
let rec subst_core_type subst core_ty = { Scopedtree . ptyp_desc = subst_core_type_desc subst core_ty . Scopedtree . ptyp_desc ; Scopedtree . ptyp_loc = core_ty . Scopedtree . ptyp_loc } | Scopedtree . Ptyp_any as whatever -> whatever | Scopedtree . Ptyp_var _ as whatever -> whatever | Scopedtree . Ptyp_arrow ( neg , p... |
let rec subst_expression subst expr = { Scopedtree . pexp_desc = subst_expression_desc subst expr . Scopedtree . pexp_desc ; Scopedtree . pexp_loc = expr . Scopedtree . pexp_loc } Scopedtree . Pexp_ident path -> Scopedtree . Pexp_ident ( Subst . path path subst ) | Scopedtree . Pexp_constant _ as whatever -> whatever |... |
let subst_type_kind subst = function | Scopedtree . Ptype_abstract as whatever -> whatever | Scopedtree . Ptype_variant constructors -> let constructors ' = Scopedtree . Ptype_variant constructors ' | Scopedtree . Ptype_record fields -> let fields ' = Scopedtree . Ptype_record fields ' ; ; |
let subst_type_declaration subst ty_decl = let cstrs ' = List . map ( fun ( ct1 , ct2 , loc ) -> let ct1 ' = subst_core_type subst ct1 in let ct2 ' = subst_core_type subst ct2 in ty_decl . Scopedtree . ptype_cstrs in let manifest ' = ( match ty_decl . Scopedtree . ptype_manifest with None -> None | Some core_ty -> Some... |
let subst_exception_declaration subst = function | None -> None | Some corety -> let corety ' = subst_core_type subst corety in Some corety ' ; ; |
let rec subst_module_expr subst mod_expr = { Scopedtree . pmod_desc = subst_module_expr_desc subst mod_expr . Scopedtree . pmod_desc ; Scopedtree . pmod_loc = mod_expr . Scopedtree . pmod_loc } | Scopedtree . Pmod_ident path -> Scopedtree . Pmod_ident ( Subst . path path subst ) | Scopedtree . Pmod_structure structure ... |
let rec is_pattern_absorbant pattern = match pattern . Scopedtree . ppat_desc with | Scopedtree . Ppat_any -> true | Scopedtree . Ppat_var _ -> true | Scopedtree . Ppat_alias ( pat , _ ) -> is_pattern_absorbant pat | Scopedtree . Ppat_constant _ -> false | Scopedtree . Ppat_tuple arg_pats -> List . for_all is_pattern_a... |
let row_remove_constant string_of_constant ( pel , rv ) = let rec rec_remove = function | [ ] -> raise Unused_pattern | elem :: rem -> match elem with | Typecore . Constant ( val_name , _ ) when val_name = string_of_constant -> | bof -> bof :: rec_remove rem in ( rec_remove pel , rv ) ; ; |
let string_of_constant = function | Asttypes . Const_int i -> string_of_int i | Asttypes . Const_char c -> Char . escaped c | Asttypes . Const_string s -> s | Asttypes . Const_float flstr -> flstr ; ; |
let substract_constant_approx constant_string phi = let phi = Typecore . phi_repr phi in match phi . Typecore . phi_value with | Typecore . Pexplicit row -> { Typecore . phi_value = | Typecore . Pbottom -> { Typecore . phi_value = Typecore . Pbottom ; ; ; |
let rec row_remove_param env constant_string pat ( pel , rv ) = let rec rec_remove = function | [ ] -> raise Unused_pattern | elem :: rem -> match elem with | Typecore . Param ( val_name , ty ) | _ -> let ( b , l ) = rec_remove pel in ( b , ( l , rv ) ) let approx = Typecore . phi_repr approx in match approx . Typecore... |
module type S = sig type base type t include Container . S0 with type t := t with type elt := char val base : t -> base val pos : t -> int val get : t -> int -> char val create : ? pos : int -> ? len : int -> base -> t val sub : ? pos : int -> ? len : int -> t -> t val blit_to_string : t -> dst : bytes -> dst_pos : int... |
module type Type = sig type t val get : t -> int -> UChar . t val init : int -> ( int -> UChar . t ) t -> t val length : t -> int type index val look : t -> index -> UChar . t val nth : t -> int -> index val first : t -> index val last : t -> index val next : t -> index -> index val prev : t -> index -> index val move ... |
module Make ( Text : UnicodeString . Type ) Type = struct type t = Text . t * Text . index * Text . index type index = Text . index let out_of_range ( t , i0 , j ) j i = if Text . compare_index t i0 i > 0 then true else if Text . compare_index t i j >= 0 then true else Text . out_of_range t i let look ( ( t , _ , _ ) _... |
module Status = struct type t = | Data_only | Normal | Vendored module Map = struct type ' a t = { data_only : ' a ; vendored : ' a ; normal : ' a } let merge x y ~ f = { data_only = f x . data_only y . data_only ; vendored = f x . vendored y . vendored ; normal = f x . normal y . normal } let find { data_only ; vendor... |
let status status_by_dir ~ dir : Status . Or_ignored . t = match String . Map . find status_by_dir dir with | None -> Ignored | Some d -> Status d |
let default = let standard_dirs = Predicate_lang . Glob . of_pred ( function | " " -> false | s -> s . [ 0 ] <> ' . ' && s . [ 0 ] <> ' _ ' ) in { Status . Map . normal = standard_dirs ; data_only = Predicate_lang . empty ; vendored = Predicate_lang . empty } |
let or_default ( t : _ Status . Map . t ) : _ Status . Map . t = Status . Map . init ~ f ( : fun kind -> match Status . Map . find t kind with | None -> Status . Map . find default kind | Some ( _loc , s ) -> s ) |
let make ~ dirs ~ data_only ~ ignored_sub_dirs ~ vendored_dirs = let data_only = match ( data_only , ignored_sub_dirs ) with | None , [ ] -> None | Some ( loc , data_only ) , [ ] -> Some ( loc , data_only ) | None , ( loc , _ ) :: _ -> let ignored_sub_dirs = List . map ~ f : snd ignored_sub_dirs in Some ( loc , Predica... |
type status_map = Status . t String . Map . t |
let eval ( t : _ Status . Map . t ) ~ dirs = String . Set . of_list dirs |> String . Set . to_map ~ f ( : fun _ -> ( ) ) |> String . Map . filter_mapi ~ f ( : fun dir ( ) : Status . t option -> let statuses = Status . Map . merge t default ~ f ( : fun pred standard -> Predicate_lang . Glob . exec pred ~ standard dir ) ... |
type subdir_stanzas = ( Loc . t * Predicate_lang . Glob . t ) option Status . Map . t |
module Dir_map = struct type per_dir = { sexps : Dune_lang . Ast . t list ; subdir_status : subdir_stanzas } type t = { data : per_dir ; nodes : t String . Map . t } let empty_per_dir = { sexps = [ ] ; subdir_status = Status . Map . init ~ f ( : fun _ -> None ) } let empty = { data = empty_per_dir ; nodes = String . Ma... |
let descendant_path = Dune_lang . Decoder . plain_string ( fun ~ loc fn -> if Filename . is_relative fn then Path . Local . parse_string_exn ~ loc fn |> Path . Local . explode else let msg = [ Pp . textf " invalid sub - directory path % S " fn ] in let hints = [ Pp . textf " sub - directory path must be relative " ] in... |
let strict_subdir field_name = let open Dune_lang . Decoder in plain_string ( fun ~ loc dn -> let msg = [ Pp . textf " invalid sub - directory name % S " dn ] in if Filename . dirname dn <> Filename . current_dir_name then let msg = [ Pp . textf " only immediate sub - directories may be specified . " ] in let hints = [... |
let strict_subdir_glob field_name = let open Dune_lang . Decoder in let + globs = repeat ( let + loc , l = strict_subdir field_name in Predicate_lang . Glob . of_glob ( Glob . of_string_exn loc l ) ) in Predicate_lang . union globs |
let decode = let open Dune_lang . Decoder in let ignored_sub_dirs = let ignored = let + l = enter ( repeat ( strict_subdir " ignored_sub_dirs " ) ) in Predicate_lang . Glob . of_string_set ( String . Set . of_list_map ~ f : snd l ) in let + version = Dune_lang . Syntax . get_exn Stanza . syntax and + loc , ignored = lo... |
let decode_includes ~ context = let open Dune_lang . Decoder in let rec subdir ~ context ~ path ~ inside_include = let * dune_version = Dune_lang . Syntax . get_exn Stanza . syntax in let * loc = loc in let * name , path = plain_string ( fun ~ loc s -> ( Dune_lang . Ast . atom_or_quoted_string loc s , s :: path ) ) in ... |
let decode ~ file = let open Dune_lang . Decoder in let * sexps = decode_includes ~ context ( : Include_stanza . in_file file ) in let * ( ) = set_input [ List ( Loc . none , sexps ) ] in decode |
module Register_backend ( M : Backend ) = struct include Sub_system_info . Register ( M . Info ) include Lib . Sub_system . Register ( struct include M type Lib . Sub_system . t += T of t let public_info = Some public_info end ) let top_closure l ~ deps = let open Resolve . Memo . O in Lib . L . top_closure l ~ key : M... |
type Lib . Sub_system . t += Gen of ( Library_compilation_context . t -> unit Memo . t ) |
module Register_end_point ( M : End_point ) = struct include Sub_system_info . Register ( M . Info ) let gen info ( c : Library_compilation_context . t ) = let open Memo . O in let * backends = let ( let & ) t f = Resolve . Memo . bind t ~ f in let & deps = Lib . Compile . direct_requires c . compile_info in let & pps ... |
let gen_rules ( c : Library_compilation_context . t ) = let * l = Lib . Compile . sub_systems c . compile_info in Memo . parallel_iter l ~ f ( : function | Gen gen -> gen c | _ -> Memo . return ( ) ) |
let equal ( x : t ) ( y : t ) = x == y |
type sub_system = t = . . |
module type S = sig type t type sub_system += T of t val name : Sub_system_name . t val loc : t -> Loc . t val syntax : Dune_lang . Syntax . t val decode : t Dune_lang . Decoder . t val encode : t -> Dune_lang . Syntax . Version . t * Dune_lang . t list end |
let all = Sub_system_name . Table . create 16 |
let record_parser = ref return |
module Register ( M : S ) : sig end = struct open M let ( ) = match Sub_system_name . Table . find all name with | Some _ -> Code_error . raise " Sub_system_info . register : already registered " [ ( " name " , Dyn . string ( Sub_system_name . to_string name ) ) ] | None -> ( Sub_system_name . Table . set all name ( mo... |
let record_parser ( ) = ! record_parser Sub_system_name . Map . empty |
let get name = Sub_system_name . Table . find_exn all name |
module type Info = Sub_system_info . S |
module type S = sig module Info : Info type t val instantiate : resolve ( : Loc . t * Lib_name . t -> Lib . t Resolve . Memo . t ) -> get ( : loc : Loc . t -> Lib . t -> t option Memo . t ) -> Lib . t -> Info . t -> t Memo . t end |
module type Backend = sig include S val desc : plural : bool -> string val desc_article : string val lib : t -> Lib . t val public_info : t -> Info . t Resolve . Memo . t end |
module type Registered_backend = sig type t val get : Lib . t -> t option Memo . t val resolve : Lib . DB . t -> Loc . t * Lib_name . t -> t Resolve . Memo . t module Selection_error : sig type nonrec t = | Too_many_backends of t list | No_backend_found val to_lib_resolve : ( ' a , t ) result -> loc : Loc . t -> ' a Re... |
module Library_compilation_context = struct type t = { super_context : Super_context . t ; dir : Path . Build . t ; stanza : Dune_file . Library . t ; scope : Scope . t ; source_modules : Module . t list ; compile_info : Lib . Compile . t } end |
module type End_point = sig module Backend : sig include Registered_backend val extends : t -> t list Resolve . t end module Info : sig include Info val backends : t -> ( Loc . t * Lib_name . t ) list option end val gen_rules : Library_compilation_context . t -> info : Info . t -> backends : Backend . t list -> unit Me... |
type metadata = { title : string ; logo : string ; background : string ; theme : string ; synopsis : string ; url : string ; } |
let path = Fpath . v " data / success_stories " / |
let parse content = let metadata , _ = Utils . extract_metadata_body content in metadata_of_yaml metadata |
type t = { title : string ; slug : string ; logo : string ; background : string ; theme : string ; synopsis : string ; url : string ; body_md : string ; body_html : string ; } |
let all ( ) = Utils . map_files ( fun content -> let metadata , body = Utils . extract_metadata_body content in let metadata = Utils . decode_or_raise metadata_of_yaml metadata in { title = metadata . title ; slug = Utils . slugify metadata . title ; logo = metadata . logo ; background = metadata . background ; theme =... |
let pp ppf v = Fmt . pf ppf { | { title = % a ; slug = % a ; logo = % a ; background = % a ; theme = % a ; synopsis = % a ; url = % a ; body_md = % a ; body_html = % a } } | Pp . string v . title Pp . string v . slug Pp . string v . logo Pp . string v . background Pp . string v . theme Pp . string v . synopsis Pp . str... |
let pp_list = Pp . list pp |
let template ( ) = Format . asprintf { | |
type t = { title : string ; slug : string ; logo : string ; background : string ; theme : string ; synopsis : string ; url : string ; body_md : string ; body_html : string } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.