package caqti

  1. Overview
  2. Docs
Unified interface to relational database libraries

Install

dune-project
 Dependency

Authors

Maintainers

Sources

caqti-v3.0.0.tbz
sha256=3ceea06ba0e8e8bcab0386b5817b68cb30fce457eaa25ada0182891d66f6a0b9
sha512=e01f546a45b04cafd5fa262e9228e5a1aabd5e0942059c073a4181c928450baf3d990cc59ffb1a33dff445b46a0e218224a23dca96e8d24cdd0ab793d08e4538

doc/caqti.platform/Caqti_platform/Pool/Make/argument-1-System/Stream/index.html

Module System.Stream

type ('a, 'err) t = unit -> ('a, 'err) node Fiber.t

A stream, represented as a lazy chain of Cons-nodes terminating in a Nil or an Error.

and ('a, 'err) node =
  1. | Nil
    (*

    The node of an empty stream

    *)
  2. | Error of 'err
    (*

    A node of a permanently failed stream.

    *)
  3. | Cons of 'a * ('a, 'err) t
    (*

    A node holding the next element and continuation of a stream.

    *)
val empty : ('a, 'err) t

empty is the empty stream, i.e. it immediately returns Nil.

val error : 'err -> ('a, 'err) t

error err is a stream which fails immediately with err.

val fold : f:('a -> 'state -> 'state) -> ('a, 'err) t -> 'state -> ('state, 'err) result Fiber.t

fold ~f stream acc consumes the remainder elements e1, ..., eN of stream and returns Ok (acc |> f e1 |> ... |> f eN) if no error occurred

val fold_s : f:('a -> 'state -> ('state, 'err) result Fiber.t) -> ('a, 'clog) t -> 'state -> ('state, [> `Congested of 'clog ] as 'err) result Fiber.t

fold_s ~f stream acc consumes the remainder of stream, passing each element in order to f along with the latest accumulation starting at acc, and returning the final accumulation if successful. An error result may be due to either the stream provider or the callback, as distinguished with the `Congested constructor.

val iter_s : f:('a -> (unit, 'err) result Fiber.t) -> ('a, 'clog) t -> (unit, [> `Congested of 'clog ] as 'err) result Fiber.t

iter_s ~f stream consumes the remainder of stream, passing each element in order to f. An error result may be due to either the steram provider or the callback, as distinguished with the `Congested constructor.

val to_rev_list : ('a, 'err) t -> ('a list, 'err) result Fiber.t

to_rev_list stream consumes the remainder of stream, returning a list of its element in reverse order of production.

val to_list : ('a, 'err) t -> ('a list, 'err) result Fiber.t

to_list stream consumes the remainder of stream, returning a list of its element in order of production.

val of_list : 'a list -> ('a, 'err) t

of_list xs is a non-failing finite stream (re)producing the elements xs in order of occurrence.

val map_result : f:('a -> ('b, 'err) result) -> ('a, 'err) t -> ('b, 'err) t