package csexp

  1. Overview
  2. Docs

Parameters

module Sexp : Sexp

Signature

Parsing

include module type of Result
include module type of struct include Stdlib.Result end
type (!'a, !'e) t = ('a, 'e) Stdlib.result =
  1. | Ok of 'a
  2. | Error of 'e
val ok : 'a -> ('a, 'e) Stdlib.result
val error : 'e -> ('a, 'e) Stdlib.result
val value : ('a, 'e) Stdlib.result -> default:'a -> 'a
val get_ok : ('a, 'e) Stdlib.result -> 'a
val get_error : ('a, 'e) Stdlib.result -> 'e
val bind : ('a, 'e) Stdlib.result -> ('a -> ('b, 'e) Stdlib.result) -> ('b, 'e) Stdlib.result
val join : (('a, 'e) Stdlib.result, 'e) Stdlib.result -> ('a, 'e) Stdlib.result
val map : ('a -> 'b) -> ('a, 'e) Stdlib.result -> ('b, 'e) Stdlib.result
val map_error : ('e -> 'f) -> ('a, 'e) Stdlib.result -> ('a, 'f) Stdlib.result
val fold : ok:('a -> 'c) -> error:('e -> 'c) -> ('a, 'e) Stdlib.result -> 'c
val iter : ('a -> unit) -> ('a, 'e) Stdlib.result -> unit
val iter_error : ('e -> unit) -> ('a, 'e) Stdlib.result -> unit
val is_ok : ('a, 'e) Stdlib.result -> bool
val is_error : ('a, 'e) Stdlib.result -> bool
val equal : ok:('a -> 'a -> bool) -> error:('e -> 'e -> bool) -> ('a, 'e) Stdlib.result -> ('a, 'e) Stdlib.result -> bool
val compare : ok:('a -> 'a -> int) -> error:('e -> 'e -> int) -> ('a, 'e) Stdlib.result -> ('a, 'e) Stdlib.result -> int
val to_option : ('a, 'e) Stdlib.result -> 'a option
val to_list : ('a, 'e) Stdlib.result -> 'a list
val to_seq : ('a, 'e) Stdlib.result -> 'a Stdlib.Seq.t
type ('a, 'b) result = ('a, 'b) Stdlib.Result.t =
  1. | Ok of 'a
  2. | Error of 'b
val parse_string : string -> (Sexp.t, int * string) result

parse_string s parses a single S-expression encoded in canonical form in s. It is an error for s to contain a S-expression followed by more data. In case of error, the offset of the error as well as an error message is returned.

val parse_string_many : string -> (Sexp.t list, int * string) result

parse_string s parses a sequence of S-expressions encoded in canonical form in s

val input : Stdlib.in_channel -> (Sexp.t, string) result

Read exactly one canonical S-expressions from the given channel. Note that this function never raises End_of_file. Instead, it returns Error.

val input_opt : Stdlib.in_channel -> (Sexp.t option, string) result

Same as input but returns Ok None if the end of file has already been reached. If some more characters are available but the end of file is reached before reading a complete S-expression, this function returns Error.

val input_many : Stdlib.in_channel -> (Sexp.t list, string) result

Read many S-expressions until the end of input is reached.

Serialising

val serialised_length : Sexp.t -> int

The length of the serialised representation of a S-expression

val to_string : Sexp.t -> string

to_string sexp converts S-expression sexp to a string in canonical form.

val to_buffer : Stdlib.Buffer.t -> Sexp.t -> unit

to_buffer buf sexp outputs the S-expression sexp converted to its canonical form to buffer buf.

val to_channel : Stdlib.out_channel -> Sexp.t -> unit

output oc sexp outputs the S-expression sexp converted to its canonical form to channel oc.

Low level parser

Low level parsing interface with fine-grain control over the input monad. Suitable for Lwt or Async integration.

module type Input = sig ... end
module Make_parser (Input : Input) : sig ... end
OCaml

Innovation. Community. Security.