package opentelemetry-client

  1. Overview
  2. Docs

Source file generic_io.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(** Generic IO monad.

    This factors out some logic between various concurrency frameworks. *)

module type S = sig
  type 'a t

  val return : 'a -> 'a t

  val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t

  val protect : finally:(unit -> unit t) -> (unit -> 'a t) -> 'a t
end

module type S_WITH_CONCURRENCY = sig
  include S

  val sleep_s : float -> unit t

  val spawn : (unit -> unit t) -> unit
end

module Direct_style : S with type 'a t = 'a = struct
  type 'a t = 'a

  let[@inline] return x = x

  let[@inline] ( let* ) x f = f x

  let protect = Fun.protect
end