package camlon

  1. Overview
  2. Docs
type t =
  1. | Bool of bool
  2. | Int31 of int
    (*

    int for 32 bit arch

    *)
  3. | Int63 of int64
    (*

    int for 64 bit arch

    *)
  4. | Int32 of int32
  5. | Int64 of int64
  6. | Nativeint32 of int32
    (*

    natint for 32 bit arch

    *)
  7. | Nativeint64 of int64
    (*

    natint for 64 bit arch

    *)
  8. | Float of float
  9. | Char of char
  10. | String of string
  11. | List of t list
  12. | Array of t list
  13. | Variant of string * t list
    (*

    Variants.

    *)
  14. | Poly_variant of string * t list
    (*

    Polymorphic variants

    *)
  15. | Record of (string * t) list
  16. | Object of (string * t) list
    (*

    Object

    *)
  17. | Tuple of t list
  18. | Unit
  19. | Escaped of string
    (*

    Something outside of OCaml values

    *)

The data type.

Note on lists:

* List literals [..], including the null list [], are parsed and prnited as List .., not with Variant (..). * Cons cells x::xs are parsed and printed using Variant (..).

Record style Variant arguments are expressed as Varaint (Record ..).

type ocaml = t
val escape_string : string -> string

Escape the special characters of the given string like String.escaped.

String.escaped and the format string's "%S" is too mean for UTF8 strings. escape_string does not escape characters whose code is more than 128.

This function returns the argument itself if there is no need of escaping.

val format : Format.formatter -> t -> unit

Formatter of type t

val format_no_poly : Format.formatter -> t -> unit

Formatter of type t. Same as format, but prints polymorphic variants and objects as variants and records

val format_with : ('a -> t) -> Format.formatter -> 'a -> unit

Same as format but, but prints polymorphic variants and objects as variants and records

val format_no_poly_with : ('a -> t) -> Format.formatter -> 'a -> unit

Same as format_with but

module Parser : sig ... end
type 'a load_error = [
  1. | `Conv of 'a
  2. | Parser.error
]
val load : string -> (t list, Parser.error) result

Load values of t printed in a file

val load_with : (t -> ('a, 'b) result) -> string -> ('a list, 'b load_error) result

Load values of t printed in a file, then convert them using the decoder

val save : perm:int -> ?no_poly:bool -> string -> t list -> unit

Save values of t to a file

val save_with : ('a -> t) -> perm:int -> ?no_poly:bool -> string -> 'a list -> unit

Save OCaml values to a file, converting them to type t

OCaml

Innovation. Community. Security.