package ocamlformat-rpc-lib

  1. Overview
  2. Docs

Parameters

module IO : IO

Signature

module V1 : sig ... end
module V2 : sig ... end
type client = [
  1. | `V1 of V1.Client.t
  2. | `V2 of V2.Client.t
]
val pick_client : pid:int -> IO.ic -> IO.oc -> string list -> (client, [ `Msg of string ]) result IO.t

The RPC offers multiple versions of the API. pick_client ~pid in out versions handles the interaction with the server to agree with a common version of the RPC to use. Trying successively each version of the provided list versions until the server agrees, for this reason you might want to list newer versions before older versions. The given IO.ic and IO.oc values are referenced by the client value and must be kept open until halt is called.

val pid : client -> int
val halt : client -> (unit, [> `Msg of string ]) result IO.t

Tell the server to close the connection. No more commands can be sent using the same client value.

val config : (string * string) list -> client -> (unit, [> `Msg of string ]) result IO.t
  • before v2
val format : ?format_args:format_args -> string -> client -> (string, [> `Msg of string ]) result IO.t

format_args modifies the server's configuration temporarily, for the current request.

  • before v2

    When using v1, format_args will be ignored.

A basic interaction could be:

RPC.config [("profile", "ocamlformat")] client >>= fun () ->
RPC.format "let x = 4 in x" client >>= fun formatted ->
...
RPC.halt client >>= fun () ->
...
OCaml

Innovation. Community. Security.