this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

More tidying

+49 -31
+3 -13
example/example.ml
··· 17 17 Option.iter (fun s -> log ("sharp_ppf: " ^ s)) o.sharp_ppf; 18 18 Option.iter (fun s -> log ("caml_ppf: " ^ s)) o.caml_ppf 19 19 20 - let start rpc = 20 + let _ = 21 21 let ( let* ) = Lwt_result.bind in 22 + let* rpc = initialise "worker.js" (fun _ -> log "Timeout") in 22 23 let* o = W.setup rpc () in 23 24 log_output o; 24 - Lwt.return (Ok o) 25 - 26 - let exec rpc txt = 27 - let ( let* ) = Lwt_result.bind in 28 - let* o = W.exec rpc txt in 25 + let* o = W.exec rpc "2*2;;" in 29 26 log_output o; 30 - Lwt.return (Ok o) 31 - 32 - let _ = 33 - let ( let* ) = Lwt_result.bind in 34 - let* rpc = initialise "worker.js" (fun _ -> log "Timeout") in 35 - let* _ = start rpc in 36 - let* _ = exec rpc "2*2;;" in 37 27 Lwt.return (Ok ())
+10
idl/js_top_worker_client.ml
··· 61 61 module Wraw = Toplevel_api_gen.Make (Rpc_lwt.GenClient ()) 62 62 63 63 module W : sig 64 + type init_libs = Toplevel_api_gen.init_libs 65 + type err = Toplevel_api_gen.err 66 + type exec_result = Toplevel_api_gen.exec_result 67 + type completion_result = Toplevel_api_gen.completion_result 68 + 64 69 val init : 65 70 rpc -> 66 71 Toplevel_api_gen.init_libs -> ··· 81 86 string -> 82 87 (Toplevel_api_gen.completion_result, Toplevel_api_gen.err) result Lwt.t 83 88 end = struct 89 + type init_libs = Toplevel_api_gen.init_libs 90 + type err = Toplevel_api_gen.err 91 + type exec_result = Toplevel_api_gen.exec_result 92 + type completion_result = Toplevel_api_gen.completion_result 93 + 84 94 let init rpc a = Wraw.init rpc a |> Rpc_lwt.T.get 85 95 let setup rpc a = Wraw.setup rpc a |> Rpc_lwt.T.get 86 96 let exec rpc a = Wraw.exec rpc a |> Rpc_lwt.T.get
+35 -17
idl/js_top_worker_client.mli
··· 9 9 this exception. *) 10 10 11 11 type rpc = Rpc.call -> Rpc.response Lwt.t 12 + (** RPC function for communicating with the worker. This is used by each 13 + RPC function declared in {!W} *) 12 14 13 15 val start : string -> int -> (unit -> unit) -> rpc 14 16 (** [start url timeout timeout_fn] initialises a web worker from [url] and 15 17 starts communications with it. [timeout] is the number of seconds to wait 16 18 for a response from any RPC before raising an error, and [timeout_fn] is 17 - called when a timeout occurs. *) 19 + called when a timeout occurs. Returns the {!type-rpc} function used 20 + in the RPC calls. *) 18 21 19 22 module W : sig 20 - val init : 21 - rpc -> 22 - Toplevel_api_gen.init_libs -> 23 - (unit, Toplevel_api_gen.err) result Lwt.t 23 + (** {2 Type declarations} 24 + 25 + The following types are redeclared here for convenience. *) 24 26 25 - val setup : 26 - rpc -> 27 - unit -> 28 - (Toplevel_api_gen.exec_result, Toplevel_api_gen.err) result Lwt.t 27 + type init_libs = Toplevel_api_gen.init_libs 28 + type err = Toplevel_api_gen.err 29 + type exec_result = Toplevel_api_gen.exec_result 30 + type completion_result = Toplevel_api_gen.completion_result 29 31 30 - val exec : 31 - rpc -> 32 - string -> 33 - (Toplevel_api_gen.exec_result, Toplevel_api_gen.err) result Lwt.t 32 + (** {2 RPC calls} 33 + 34 + The first parameter of these calls is the rpc function returned by 35 + {!val-start}. If any of these calls fails to receive a response from 36 + the worker by the timeout set in the {!val-start} call, the {!Lwt} 37 + thread will be {{!Lwt.fail}failed}. 38 + *) 34 39 35 - val complete : 36 - rpc -> 37 - string -> 38 - (Toplevel_api_gen.completion_result, Toplevel_api_gen.err) result Lwt.t 40 + val init : rpc -> init_libs -> (unit, err) result Lwt.t 41 + (** Initialise the toplevel. This must be called before any other API. *) 42 + 43 + val setup : rpc -> unit -> (exec_result, err) result Lwt.t 44 + (** Start the toplevel. Return value is the initial blurb 45 + printed when starting a toplevel. Note that the toplevel 46 + must be initialised first. *) 47 + 48 + val exec : rpc -> string -> (exec_result, err) result Lwt.t 49 + (** Execute a phrase using the toplevel. The toplevel must have been 50 + Initialised first. *) 51 + 52 + val complete : rpc -> string -> (completion_result, err) result Lwt.t 53 + (** Find completions of the incomplete phrase. Completion occurs at the 54 + end of the phrase passed in. If completion is required at a point 55 + other than the end of a string, then take the substring before calling 56 + this API. *) 39 57 end
+1 -1
idl/toplevel_api.ml
··· 77 77 78 78 let init = 79 79 declare "init" 80 - [ "Initialise the toplevel." ] 80 + [ "Initialise the toplevel. This must be called before any other API." ] 81 81 (init_libs @-> returning unit_p err) 82 82 83 83 let setup =