text stringlengths 0 601k |
|---|
let clear ( t : t ) key = let key = redis_key key in Lwt_pool . use t . pool @@ fun conn -> R . del conn [ key ] >|= fun ( _ : int ) -> ( ) |
let get ( t : t ) key = let key = redis_key key in Lwt_pool . use t . pool @@ fun conn -> R . get conn key >>= function | None -> Lwt . return ( Error Session . S . Not_found ) | Some " " - -> Lwt . return ( Error Session . S . Not_set ) | Some encoded_value -> R . ttl conn key >|= function | None -> Error Session . S ... |
let set_opt ? expiry t key value = let key = redis_key key in let ex = match expiry with | None -> default_period t | Some x -> x in let value = match value with | None -> " " - | Some v -> " " + ^ v in if ex < 0L then Lwt . return_unit else ( Lwt_pool . use t . pool @@ fun conn -> R . set conn ~ ex ( : Int64 . to_int ... |
let set ? expiry t key value = set_opt ? expiry t key ( Some value ) |
let generate ? expiry ? value ( t : t ) = let key = gensym ( ) in set_opt ? expiry t key value >|= fun ( ) -> key |
module type Backend = Session_cohttp . Backend |
module type S = sig include Session_cohttp . S class [ ' body ] manager : cookie_key : string -> backend -> object method private session_of_rd : ' body Rd . t -> ( t option , Session . S . error ) result io method private session_of_rd_or_create : ? expiry : period -> value -> ' body Rd . t -> t io method private sess... |
module Make ( IO : Session . S . IO ) ( B : Backend with type ' + a io = ' a IO . t ) = struct include Session_cohttp . Make ( IO ) ( B ) type s = [ ` Uninitialized | ` Cached of t | ` Cleared ] open IO let ( ) >>| a f = a >>= fun x -> return ( f x ) class [ ' body ] manager ~ cookie_key backend = let __session : s ref... |
module Make = functor ( HC : Aws_sigs . HTTP_CLIENT ) -> struct |
type send_data_points = { bounce : int ; complaints : int ; delivery_attempts : int ; rejects : int ; timestamp : float ; } |
type destination = { bcc_addresses : string list ; cc_addresses : string list ; to_addresses : string list ; } |
type content = { charset : string ; data : string ; } |
type body = { html : content ; text : content ; } |
type message = { subject : content ; body : body ; } |
let check_error xml = try let e = X . nodes_of_string " ErrorResponse . Error " xml in let type_ = X . data_of_string " Type " e in let code = X . data_of_string " Code " e in let message = X . data_of_string " Message " e in raise ( Ses_error ( type_ , code , message ) ) with Not_found -> ( ) |
let build_ses_header ~ creds = let date = CalendarLib . Printer . Calendar . sprint " % a , % d % b % Y % T % z " ( CalendarLib . Calendar . now ( ) ) in let hmac_sha1_encoder = ( Cryptokit . MAC . hmac_sha1 creds . Creds . aws_secret_access_key ) in let sign = Cryptokit . hash_string hmac_sha1_encoder date in let sign... |
let ses_timestamp ( ) = CalendarLib . Printer . Calendar . sprint " % FT % T . 000Z " ( CalendarLib . Calendar . now ( ) ) |
let make_request ~ creds post_params = let headers = build_ses_header ~ creds in let post_params = [ ( " AWSAccessKeyId " , creds . Creds . aws_access_key_id ) ; ( " Timestamp " , ses_timestamp ( ) ) ] @ post_params in let body = ` String ( Util . encode_post_url post_params ) in lwt _ , s = HC . post ~ headers ~ body ... |
let delete_verified_email_address ~ creds email = lwt _ = make_request ~ creds [ ( " Action " , " DeleteVerifiedEmailAddress " ) ; ( " EmailAddress " , email ) ; ] in Lwt . return ( ) |
let get_send_quota ~ creds = lwt xml = make_request ~ creds [ ( " Action " , " GetSendQuota " ) ; ] in let t = X . nodes_of_string " GetSendQuotaResponse . GetSendQuotaResult " xml in let max_24_hour_send = float_of_string ( X . data_of_string " Max24HourSend " t ) in let max_send_rate = float_of_string ( X . data_of_s... |
let get_send_statistics ~ creds = lwt xml = make_request ~ creds [ ( " Action " , " GetSendStatistics " ) ; ] in let t = X . nodes_of_string " GetSendStatisticsResponse . GetSendStatisticsResult . SendDataPoints " xml in let l = List . fold_left ( fun datas -> function | X . E ( " member " , _ , xml ) -> let timestamp ... |
let list_verified_email_addresses ~ creds = lwt xml = make_request ~ creds [ ( " Action " , " ListVerifiedEmailAddresses " ) ; ] in let t = X . nodes_of_string " ListVerifiedEmailAddressesResponse . ListVerifiedEmailAddressesResult . VerifiedEmailAddresses " xml in let l = List . fold_left ( fun acc -> function | X . E... |
let build_member dest dest_type acc = let l , _ = List . fold_left ( fun ( acc , nb ) email -> if email <> " " then begin let k = Printf . sprintf " % s . member . % d " dest_type nb in let acc = ( k , email ) :: acc in acc , nb + 1 end else ( acc , nb ) ) ( acc , 1 ) dest in l |
let send_email ~ creds ? reply_to_addresses ? return_path ~ destination ~ source ~ message ( ) = let build_members dests acc = let acc = build_member dests . to_addresses " Destination . ToAddresses " acc in let acc = build_member dests . bcc_addresses " Destination . BccAddresses " acc in let acc = build_member dests ... |
let send_raw_email ~ creds ? destinations ? source ~ raw_message ( ) = let build_members dests acc = match dests with | Some d -> build_member d " Destinations " acc | None -> acc in let params = match source with | Some s -> [ ( " Source " , s ) ; ( " Action " , " SendRawEmail " ) ] ; | None -> [ ( " Action " , " Send... |
let verify_email_address ~ creds email = lwt xml = make_request ~ creds [ ( " Action " , " VerifyEmailIdentity " ) ; ( " EmailAddress " , email ) ; ] in Lwt . return ( X . data_of_string " VerifyEmailIdentityResponse . ResponseMetadata . RequestId " [ xml ] ) |
let send_basic_email ~ creds ? message_text ? bcc ? cc ? charset ? reply_to_addresses ? return_path ~ from_ ~ to_ ~ subject ~ message_html ( ) = let destination = { to_addresses = to_ ; bcc_addresses = ( match bcc with | Some bcc -> bcc | None -> [ ] ) ; cc_addresses = ( match cc with | Some cc -> cc | None -> [ ] ) ; ... |
let get_raw_send_statistics ~ creds = lwt stats = get_send_statistics ~ creds in Lwt . return ( List . map ( fun s -> ( s . bounce , s . complaints , s . delivery_attempts , s . rejects , s . timestamp ) ) stats ) end |
let [ @ inline ] eq_elt ( x : elt ) y = x = y |
let compare_elt ( x : elt ) ( y : elt ) = let a = Int . compare ( Ext_ident . stamp x ) ( Ext_ident . stamp y ) in if a <> 0 then a else let b = String . compare ( Ident . name x ) ( Ident . name y ) in if b <> 0 then b else Int . compare ( Ident . scope x ) ( Ident . scope y ) |
let [ @ inline ] eq_elt ( x : elt ) y = Ident . same x y |
let [ @ inline ] eq_elt ( x : elt ) y = x = y # else # endif |
type ( ' a ) t0 = ' a Set_gen . t |
type t = elt t0 |
let rec mem ( tree : t ) ( x : elt ) = match tree with | Empty -> false | Leaf v -> eq_elt x v | Node { l ; v ; r } -> let c = compare_elt x v in c = 0 || mem ( if c < 0 then l else r ) x |
type split = | Yes of { l : t ; r : t } | No of { l : t ; r : t } |
let [ @ inline ] split_l ( x : split ) = match x with | Yes { l } | No { l } -> l |
let [ @ inline ] split_r ( x : split ) = match x with | Yes { r } | No { r } -> r |
let [ @ inline ] split_pres ( x : split ) = match x with | Yes _ -> true | No _ -> false |
let rec split ( tree : t ) x : split = match tree with | Empty -> No { l = empty ; r = empty } | Leaf v -> let c = compare_elt x v in if c = 0 then Yes { l = empty ; r = empty } else if c < 0 then No { l = empty ; r = tree } else No { l = tree ; r = empty } | Node { l ; v ; r } -> let c = compare_elt x v in if c = 0 th... |
let rec add ( tree : t ) x : t = match tree with | Empty -> singleton x | Leaf v -> let c = compare_elt x v in if c = 0 then tree else if c < 0 then Set_gen . unsafe_two_elements x v else Set_gen . unsafe_two_elements v x | Node { l ; v ; r } as t -> let c = compare_elt x v in if c = 0 then t else if c < 0 then Set_gen... |
let rec union ( s1 : t ) ( s2 : t ) : t = match ( s1 , s2 ) with | ( Empty , t ) | ( t , Empty ) -> t | Node _ , Leaf v2 -> add s1 v2 | Leaf v1 , Node _ -> add s2 v1 | Leaf x , Leaf v -> let c = compare_elt x v in if c = 0 then s1 else if c < 0 then Set_gen . unsafe_two_elements x v else Set_gen . unsafe_two_elements v... |
let rec inter ( s1 : t ) ( s2 : t ) : t = match ( s1 , s2 ) with | ( Empty , _ ) | ( _ , Empty ) -> empty | Leaf v , _ -> if mem s2 v then s1 else empty | Node ( { v } as s1 ) , _ -> let result = split s2 v in if split_pres result then Set_gen . internal_join ( inter s1 . l ( split_l result ) ) v ( inter s1 . r ( split... |
let rec diff ( s1 : t ) ( s2 : t ) : t = match ( s1 , s2 ) with | ( Empty , _ ) -> empty | ( t1 , Empty ) -> t1 | Leaf v , _ -> if mem s2 v then empty else s1 | ( Node ( { v } as s1 ) , _ ) -> let result = split s2 v in if split_pres result then Set_gen . internal_concat ( diff s1 . l ( split_l result ) ) ( diff s1 . r... |
let rec remove ( tree : t ) ( x : elt ) : t = match tree with | Empty -> empty | Leaf v -> if eq_elt x v then empty else tree | Node { l ; v ; r } -> let c = compare_elt x v in if c = 0 then Set_gen . internal_merge l r else if c < 0 then Set_gen . bal ( remove l x ) v r else Set_gen . bal l v ( remove r x ) |
let of_list l = match l with | [ ] -> empty | [ x0 ] -> singleton x0 | [ x0 ; x1 ] -> add ( singleton x0 ) x1 | [ x0 ; x1 ; x2 ] -> add ( add ( singleton x0 ) x1 ) x2 | [ x0 ; x1 ; x2 ; x3 ] -> add ( add ( add ( singleton x0 ) x1 ) x2 ) x3 | [ x0 ; x1 ; x2 ; x3 ; x4 ] -> add ( add ( add ( add ( singleton x0 ) x1 ) x2 )... |
let invariant t = Set_gen . check t ; Set_gen . is_ordered ~ cmp : compare_elt t |
let print fmt s = Format . fprintf fmt " [ @< v { >% a } ] . " @@ ( fun fmt s -> iter s ( fun e -> Format . fprintf fmt " [ @< v >% a ] , @@ " print_elt e ) ) s |
module type OrderedType = sig type t val compare : t -> t -> int end |
module type S = sig type elt type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val disjoint : t -> t -> bool val diff : t -> t -> t val compare : t -> t -> int val equal : t... |
module Make ( Ord : OrderedType ) = struct type elt = Ord . t type t = Empty | Node of { l : t ; v : elt ; r : t ; h : int } let height = function Empty -> 0 | Node { h } -> h let create l v r = let hl = match l with Empty -> 0 | Node { h } -> h in let hr = match r with Empty -> 0 | Node { h } -> h in Node { l ; v ; r ... |
let option_string = option string |
let s = " ReWeb . Header . SetCookie " , [ test_case " make - constructs all directives " ` Quick begin fun ( ) -> " 0 " |> make ~ max_age : 0 ~ secure : true ~ http_only : true ~ domain " : localhost " ~ path " :/ api " ~ same_site : Strict ~ name : cookie_name |> value |> check string " " " 0 ; Max - Age = 0 ; Secure... |
let unsupported s = raise ( Unsupported s ) |
module type S = sig include Lattice . S type elt val empty : unit -> t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val diff : t -> t -> t val subset : t -> t -> bool val iter : ( elt -> un... |
module Make ( Base : Printable . S ) : S with type elt = Base . t and type t = BatSet . Make ( Base ) . t = struct include Printable . Blank include BatSet . Make ( Base ) let name ( ) = " Set ( " ^ Base . name ( ) ^ " ) " let empty _ = empty let leq = subset let join = union let widen = join let meet = inter let narro... |
module SensitiveConf ( C : Printable . ProdConfiguration ) ( Base : Lattice . S ) ( User : Printable . S ) = struct module Elt = Printable . ProdConf ( C ) ( Base ) ( User ) include Make ( Elt ) let name ( ) = " Sensitive " ^ name ( ) let leq s1 s2 = let p ( b1 , u1 ) = exists ( fun ( b2 , u2 ) -> User . equal u1 u2 &&... |
module Sensitive = SensitiveConf ( struct let expand_fst = true let expand_snd = true end ) |
module type ToppedSetNames = sig val topname : string end |
module LiftTop ( S : S ) ( N : ToppedSetNames ) : S with type elt = S . elt and type t = [ ` Top | ` Lifted of S . t ] = struct include Printable . Std include Lattice . LiftTop ( S ) type elt = S . elt let empty ( ) = ` Lifted ( S . empty ( ) ) let is_empty x = match x with | ` Top -> false | ` Lifted x -> S . is_empt... |
module ToppedSet ( Base : Printable . S ) ( N : ToppedSetNames ) : S with type elt = Base . t and type t = [ ` Top | ` Lifted of Make ( Base ) . t ] = struct module S = Make ( Base ) include LiftTop ( S ) ( N ) end |
module HeadlessSet ( Base : Printable . S ) = struct include Make ( Base ) let name ( ) = " Headless " ^ name ( ) let pretty ( ) x = let elts = elements x in let content = List . map ( Base . pretty ( ) ) elts in let rec separate x = match x with | [ ] -> [ ] | [ x ] -> [ x ] | ( x :: xs ) -> x ++ ( text " , " ) ++ lin... |
module Reverse ( Base : S ) = struct include Base include Lattice . Reverse ( Base ) end |
module type FiniteSetElems = sig type t val elems : t list end |
module FiniteSet ( E : Printable . S ) ( Elems : FiniteSetElems with type t = E . t ) = struct module E = struct include E let arbitrary ( ) = QCheck . oneofl Elems . elems end include Make ( E ) let top ( ) = of_list Elems . elems let is_top x = equal x ( top ( ) ) end |
module S = Belt_SortArrayString # else [ % error " unknown type " ] # endif |
type t = { mutable data : I . t } |
let rec remove0 nt ( x : value ) = let k = nt . N . value in if x = k then let { N . left = l ; right = r } = nt in match l , r with | None , _ -> r | _ , None -> l | Some _ , Some nr -> nt . right <- ( N . removeMinAuxWithRootMutate nt nr ) ; Some ( N . balMutate nt ) else begin if x < k then match nt . left with | No... |
let remove d v = let oldRoot = d . data in match oldRoot with | None -> ( ) | Some oldRoot2 -> let newRoot = remove0 oldRoot2 v in if newRoot != oldRoot then d . data <- newRoot |
let rec removeMany0 t xs i len = if i < len then let ele = A . getUnsafe xs i in let u = remove0 t ele in match u with | None -> None | Some t -> removeMany0 t xs ( i + 1 ) len else Some t |
let removeMany ( d : t ) xs = let oldRoot = d . data in match oldRoot with | None -> ( ) | Some nt -> let len = A . length xs in d . data <- removeMany0 nt xs 0 len |
let rec removeCheck0 nt ( x : value ) removed = let k = nt . N . value in if x = k then let ( ) = removed . contents <- true in let { N . left = l ; right = r } = nt in match l , r with | None , _ -> r | _ , None -> l | Some _ , Some nr -> nt . right <- ( N . removeMinAuxWithRootMutate nt nr ) ; Some ( N . balMutate nt... |
let removeCheck ( d : t ) v = let oldRoot = d . data in match oldRoot with | None -> false | Some oldRoot2 -> let removed = ref false in let newRoot = removeCheck0 oldRoot2 v removed in if newRoot != oldRoot then d . data <- newRoot ; removed . contents |
let rec addCheck0 t ( x : value ) added = match t with | None -> added . contents <- true ; N . singleton x | Some nt -> let k = nt . N . value in if x = k then t else let { N . left = l ; right = r } = nt in ( if x < k then let ll = addCheck0 l x added in nt . left <- ll else nt . right <- ( addCheck0 r x added ) ; ) ... |
let addCheck ( m : t ) e = let oldRoot = m . data in let added = ref false in let newRoot = addCheck0 oldRoot e added in if newRoot != oldRoot then m . data <- newRoot ; added . contents |
let add d k = let oldRoot = d . data in let v = I . addMutate oldRoot k in if v != oldRoot then d . data <- v |
let addArrayMutate t xs = let v = ref t in for i = 0 to A . length xs - 1 do v . contents <- I . addMutate v . contents ( A . getUnsafe xs i ) done ; v . contents |
let mergeMany d arr = d . data <- addArrayMutate ( d . data ) arr |
let make ( ) = { data = None } |
let isEmpty d = N . isEmpty ( d . data ) |
let minimum d = N . minimum ( d . data ) |
let minUndefined d = N . minUndefined ( d . data ) |
let maximum d = N . maximum ( d . data ) |
let maxUndefined d = N . maxUndefined ( d . data ) |
let forEachU d f = N . forEachU ( d . data ) f |
let forEach d f = forEachU d ( fun [ @ bs ] a -> f a ) |
let reduceU d acc cb = N . reduceU ( d . data ) acc cb |
let reduce d acc cb = reduceU d acc ( fun [ @ bs ] a b -> cb a b ) |
let everyU d p = N . everyU ( d . data ) p |
let every d p = everyU d ( fun [ @ bs ] a -> p a ) |
let someU d p = N . someU ( d . data ) p |
let some d p = someU d ( fun [ @ bs ] a -> p a ) |
let size d = N . size ( d . data ) |
let toList d = N . toList ( d . data ) |
let toArray d = N . toArray ( d . data ) |
let fromSortedArrayUnsafe xs = { data = N . fromSortedArrayUnsafe xs } |
let checkInvariantInternal d = N . checkInvariantInternal ( d . data ) |
let fromArray xs = { data = I . fromArray xs } |
let cmp d0 d1 = I . cmp ( d0 . data ) ( d1 . data ) |
let eq d0 d1 = I . eq ( d0 . data ) ( d1 . data ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.