package conex

  1. Overview
  2. Docs

String, unsigned integers, logging, collections, and more

Sets, Maps, List utils

module S : Set.S with type elt = string

S is a string set.

val s_of_list : string list -> S.t

s_of_list xs transforms the string list xs to a set.

module M : Map.S with type key = string

M is a Map which keys are strings.

val filter_map : f:('a -> 'b option) -> 'a list -> 'b list

filter_map f xs is xs', a list which contains all elements where f resulted in Some _.

Result combinators

val (>>=) : ('a, 'b) result -> ('a -> ('c, 'b) result) -> ('c, 'b) result

r >>= f is f a unless r is an Error, which is propagated. Monadic bind.

val guard : bool -> 'a -> (unit, 'a) result

guard pred err is either Ok () (if pred holds), Error err otherwise.

val foldM : ('a -> 'b -> ('a, 'c) result) -> 'a -> 'b list -> ('a, 'c) result

foldM f a xs applies f to each element of xs, returns either Ok and the produced value, or Error.

val foldS : ('a -> string -> ('a, 'c) result) -> 'a -> S.t -> ('a, 'c) result

foldS f a s applies f to each element of the set s, returns either Ok and the produced value, or Error.

String

module String : sig ... end

Some String utilities implemented here to avoid external dependencies. This is a subset of Astring.

Unsigned integers

module Uint : sig ... end

64 bit unsigned integer with explicit overflow behaviour (see Uint.succ).

Logging

module type LOGS = sig ... end

LOGS is a subset of the Logs library, providing four log streams.

Format

type 'a fmt = Format.formatter -> 'a -> unit

'a fmt is the signature for pretty printers.

val pp_list : 'a fmt -> 'a list fmt

pp_list pp is a pretty printer for a list (surrounded by square brackets, elements are separated by semicolon). The pp is be a pretty printer for list elements.

File system types

type file_type =
  1. | File
  2. | Directory

The sum type of possible file types we expect

type path = string list

A path is a list of strings

val path_to_string : path -> string

path_to_string path is String.concat "/" path.

val string_to_path : string -> path

string_to_path str is String.cuts "/" str.

type item = file_type * string

An item is a type and its payload