package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Functional emitter/formatter combinators

Overview

In counterpart to

f_scan

, this module provides functional combinators for composing imperative emitters for various arbitrary output chanenls. Specializations are provided for

f_encode.emitter

, and the Buffer.t and Format.formatter types in the standard library.

Type
type ('a, 'b) t =
  1. | F of 'a -> 'b -> unit

Use ('a, 'b) t to represent an emitter on channels of type 'a for values of type 'b.

Functions
val apply : ('a, 'b) t -> 'a -> 'b -> unit

Use apply m c v to emit v on channel c with emitter m.

val nil : ('a, 'b) t

The empty emitter, performs no operation on the channel.

val seal : ('a, 'b) t -> 'b -> ('a, unit) t

Use seal m v to make an emitter that seals v within m.

val defer : ('b -> ('a, unit) t) -> ('a, 'b) t

Use defer f to make an emitter that applies f to its value to select the sealed emitter for it.

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

Use map f m to make an emitter that applies its input value to f and emits the result with m.

val coded : 'a Cf_encode.scheme -> (Cf_encode.emitter, 'a) t

Use coded sch to make a emitter combinator for sch.

val pair : ?sep:('a, unit) t -> ('a, 'b) t -> ('a, 'c) t -> ('a, 'b * 'c) t

Use pair a b to make an emitter for pairs of values where a is the emitter for the first value and b is the emitter for the second. If ~sep is provided, then it is inserted between the first and second values.

val opt : ?none:('a, unit) t -> ('a, 'b) t -> ('a, 'b option) t

Use opt m to make an emitter for optional values. If ~none is provided, this its sealed value is emitter whenever the input of m is None.

val seq : ?sep:('a, unit) t -> ('a, 'b) t -> ('a, 'b Seq.t) t

Use seq m to make an emitter for sequences where each element is emitted with m. If ~sep is provided, then its sealed value is emitted between each element of the sequence.

val group : ?sep:('a, unit) t -> ('a, unit) t Seq.t -> ('a, unit) t

Use group s to make a sealed emitter that emits all the sealed values in the sequence s. If ~sep is provided, then its sealed value is emitted between each element in the sequence.

val encl : a:('a, unit) t -> b:('a, unit) t -> ('a, 'b) t -> ('a, 'b) t

Use encl ~a ~b m to make an emitter that first emits the sealed value in a, then provides its input to m, then emits the sealed value in b.

Specializations for Buffer.t
module To_buffer : sig ... end
Specializations for Format.formatter
module To_formatter : sig ... end
OCaml

Innovation. Community. Security.