package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

containers-3.13.1.tbz
sha256=eb9b26eb2c3cf04fc5157d256eb49c43552ccb5c59c568772d70315db9669784
sha512=7f4cf5112c8047fd789c04129745dbe9783aa94390e8983f86408053b0af637e2a9cfce1559ce466b1b6ff7c01fd52d8685f5db1d1c0dda2c0aa138f90606a50

doc/containers/CCSexp/index.html

Module CCSexpSource

Handling S-expressions

  • since 3.0 moved into containers-core, previously in [containers.sexp]
Sourcetype 'a or_error = ('a, string) result
Sourcetype 'a gen = unit -> 'a option
Sourcemodule type SEXP = CCSexp_intf.SEXP
Sourcemodule type S = CCSexp_intf.S
Sourcemodule Make (Sexp : SEXP) : S with type t = Sexp.t and type loc = Sexp.loc

Basics

Sourcetype t = [
  1. | `Atom of string
  2. | `List of t list
]

A simple, structural representation of S-expressions.

include S with type t := t
include CCSexp_intf.S0 with type t := t
Sourcetype sexp = t

Re-exports

Sourceval list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

Sourceval of_int : int -> t
Sourceval of_bool : bool -> t
Sourceval of_list : t list -> t
Sourceval of_rev_list : t list -> t

Reverse the list.

Sourceval of_float : float -> t
Sourceval of_unit : t
Sourceval of_pair : (t * t) -> t
Sourceval of_triple : (t * t * t) -> t
Sourceval of_quad : (t * t * t * t) -> t
Sourceval of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

Sourceval of_field : string -> t -> t

Used to represent one record field.

Sourceval of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

Sourceval to_buf : Buffer.t -> t -> unit
Sourceval to_string : t -> string
Sourceval to_file : string -> t -> unit
Sourceval to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

Sourceval to_chan : out_channel -> t -> unit
Sourceval pp : Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

Sourceval pp_noindent : Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

Sourceval parse_string : string -> t CCSexp_intf.or_error

Parse a string.

Sourceval parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

  • since 2.8

Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).

Parse a channel into a generator of S-expressions.

Sourceval parse_chan_list : in_channel -> t list CCSexp_intf.or_error
Sourceval parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

Sourceval parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

Sourcetype loc

Locations for the S-expressions.

  • since 3.3

Parsing

Sourcetype 'a parse_result =
  1. | Yield of 'a
  2. | Fail of string
  3. | End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

Sourcemodule Decoder : sig ... end
Sourceval equal : t -> t -> bool
  • since 3.0
Sourceval compare : t -> t -> int
  • since 3.0
Sourceval atom : string -> t

Build an atom directly from a string.

OCaml

Innovation. Community. Security.

On This Page
  1. Basics