package ocamlformat-rpc-lib

  1. Overview
  2. Docs

Module Ocamlformat_rpc_lib.MakeSource

Parameters

module IO : IO

Signature

Sourcemodule V1 : sig ... end
Sourcemodule V2 : sig ... end
Sourcetype client = [
  1. | `V1 of V1.Client.t
  2. | `V2 of V2.Client.t
]
Sourceval 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.

Sourceval pid : client -> int
Sourceval 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.

Sourceval config : (string * string) list -> client -> (unit, [> `Msg of string ]) result IO.t
  • before v2
Sourceval 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.