package conex

  1. Overview
  2. Docs

String, unsigned integers, logging, collections, and more

Sets, Maps, List utils

module S : Stdlib.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 : Stdlib.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) Stdlib.result -> ('a -> ('c, 'b) Stdlib.result) -> ('c, 'b) Stdlib.result

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

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

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

val foldM : ('a -> 'b -> ('a, 'c) Stdlib.result) -> 'a -> 'b list -> ('a, 'c) Stdlib.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) Stdlib.result) -> 'a -> S.t -> ('a, 'c) Stdlib.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 = Stdlib.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.

  • raises Invalid_argument

    if path includes either "." or ".."

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

OCaml

Innovation. Community. Security.