package babel

  1. Overview
  2. Docs

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

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

Create a callee which can implement a given rpc.

val add : ('q, 's, 'u, 'e) implementation t -> rpc:('q, 's, 'u, 'e) Async_rpc_kernel.Rpc.State_rpc.t -> ('q, 's, 'u, 'e) implementation t

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

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

Map over the query type of a callee.

val map_state : ('q, 's1, 'u, 'e) implementation t -> f:('s2 -> 's1) -> ('q, 's2, 'u, 'e) implementation t

Map over the state type of a callee.

val map_update : ('q, 's, 'u1, 'e) implementation t -> f:('u2 -> 'u1) -> ('q, 's, 'u2, 'e) implementation t

Map over the update type of a callee.

Sometimes, Callee.State_rpc.map_update is not sufficient. For example, sometimes it might not be possible to convert the response to the desired type, in which case it may be appropriate to drop the value from the pipe entirely. For such cases, use Callee.map_response instead. It gives you access to the pipe itself, not just the values inside it, allowing you to use something like Pipe.filter_map.

val filter_map_update : ('q, 's, 'u1, 'e) implementation t -> f:('u2 -> 'u1 option) -> ('q, 's, 'u2, 'e) implementation t

Map over the update type of a callee, possibly filtering out some updates.

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

Map over the error type of a callee.

OCaml

Innovation. Community. Security.