package tezt-tezos

  1. Overview
  2. Docs

Runnable values.

type ('a, 'b) t = {
  1. value : 'a;
  2. run : 'a -> 'b Lwt.t;
}

Values that come with functions to handle them.

This is intended mainly for use with 'a = Process.t. Indeed, it is convenient to define functions that declare both how to spawn processes and how to read their output. Sometimes you want the output, sometimes you just want the Process.t itself (e.g. to check its exit code). Instead of defining one function for each use case, you can define a single function that returns a runnable, and use let*! when you need the output value, or let*? if you just need the process itself. There is no function to inject a value into the monad (return), as there is no need for it.

For instance, let's say you have a function which runs git log:

val git_log: unit -> (Process.t, string list) runnable

If you just want to check the exit code, use it like this:

let*? process : Process.t = git_log () in
Process.check process

If you just want to get its output, use it like this:

let*! log : string list = git_log () in
val run : ('a, 'b) t -> 'b Lwt.t

Apply the function of a runnable to its value.

val map : ('b -> 'c) -> ('a, 'b) t -> ('a, 'c) t

Convert the output of a runnable to make another runnable.

type 'a process = (Tezt.Process.t, 'a) t

Processes with associated run functions.

Typically, processes are associated to run functions that parse their output into values of type 'a. See Base.runnable for an example.

module Syntax : sig ... end

Part of the Runnable module that is intended to be opened.

OCaml

Innovation. Community. Security.