package babel

  1. Overview
  2. Docs

High level functions for working with callees in the style of Async.Rpc.Pipe_rpc.implement.

type ('q, 'r, 'e) implementation := 'q -> ('r Async_kernel.Pipe.Reader.t, 'e) Core.Result.t Async_kernel.Deferred.t
val singleton : ('q, 'r, 'e) Async_rpc_kernel.Rpc.Pipe_rpc.t -> ('q, 'r, 'e) implementation t

Create a callee which can implement a given rpc.

val add : ('q, 'r, 'e) implementation t -> rpc:('q, 'r, 'e) Async_rpc_kernel.Rpc.Pipe_rpc.t -> ('q, 'r, 'e) implementation t

Extend a callee to be able to implement a given rpc.

val map_query : ('q1, 'r, 'e) implementation t -> f:('q1 -> 'q2) -> ('q2, 'r, 'e) implementation t

Map over the query type of a callee.

val map_response : ('q, 'r1, 'e) implementation t -> f:('r2 -> 'r1) -> ('q, 'r2, 'e) implementation t

Map over the response type of a callee.

Sometimes, Callee.Pipe_rpc.map_response is not sufficient. If you use Callee.map_response instead, you can access the pipe itself, not just the values inside it.

val filter_map_response : ('q, 'r1, 'e) implementation t -> f:('r2 -> 'r1 option) -> ('q, 'r2, 'e) implementation t

Map over the response type of a callee, possibly filtering out some responses.

val map_error : ('q, 'r, 'e1) implementation t -> f:('e2 -> 'e1) -> ('q, 'r, 'e2) implementation t

Map over the error type of a callee.

OCaml

Innovation. Community. Security.