mte/unikernel/duniverse/csexp
2025-11-11 02:07:51 +01:00
..
.github 2025-11-11 02:07:51 +01:00
bench 2025-11-11 02:07:51 +01:00
src 2025-11-11 02:07:51 +01:00
test 2025-11-11 02:07:51 +01:00
.gitignore 2025-11-11 02:07:51 +01:00
.ocamlformat 2025-11-11 02:07:51 +01:00
CHANGES.md 2025-11-11 02:07:51 +01:00
csexp.opam 2025-11-11 02:07:51 +01:00
csexp.opam.template 2025-11-11 02:07:51 +01:00
dune-project 2025-11-11 02:07:51 +01:00
dune-workspace.dev 2025-11-11 02:07:51 +01:00
flake.lock 2025-11-11 02:07:51 +01:00
flake.nix 2025-11-11 02:07:51 +01:00
LICENSE.md 2025-11-11 02:07:51 +01:00
Makefile 2025-11-11 02:07:51 +01:00
README.md 2025-11-11 02:07:51 +01:00

Csexp - Canonical S-expressions

This project provides minimal support for parsing and printing S-expressions in canonical form, which is a very simple and canonical binary encoding of S-expressions.

Example

# #require "csexp";;
# module Sexp = struct type t = Atom of string | List of t list end;;
module Sexp : sig type t = Atom of string | List of t list end
# module Csexp = Csexp.Make(Sexp);;
module Csexp :
  sig
    val parse_string : string -> (Sexp.t, int * string) result
    val parse_string_many : string -> (Sexp.t list, int * string) result
    val input : in_channel -> (Sexp.t, string) result
    val input_opt : in_channel -> (Sexp.t option, string) result
    val input_many : in_channel -> (Sexp.t list, string) result
    val serialised_length : Sexp.t -> int
    val to_string : Sexp.t -> string
    val to_buffer : Buffer.t -> Sexp.t -> unit
    val to_channel : out_channel -> Sexp.t -> unit
  end
# Csexp.to_string (List [ Atom "Hello"; Atom "world!" ]);;
- : string = "(5:Hello6:world!)"