Module CCSexp.Traverse

module Traverse: sig .. end

type 'a conv = CCSexp.t -> 'a option 
A converter from S-expressions to 'a is a function sexp -> 'a option.
Since 0.4.1
val map_opt : ('a -> 'b option) -> 'a list -> 'b list option
Map over a list, failing as soon as the function fails on any element
Since 0.4.1
val list_any : 'a conv -> CCSexp.t -> 'a option
list_any f (List l) tries f x for every element x in List l, and returns the first non-None result (if any).
val list_all : 'a conv -> CCSexp.t -> 'a list
list_all f (List l) returns the list of all y such that x in l and f x = Some y
val to_int : int conv
Expect an integer
val to_string : string conv
Expect a string (an atom)
val to_bool : bool conv
Expect a boolean
val to_float : float conv
Expect a float
val to_list : CCSexp.t list conv
Expect a list
val to_list_with : (CCSexp.t -> 'a option) -> 'a list conv
Expect a list, applies f to all the elements of the list, and succeeds only if f succeeded on every element
Since 0.4.1
val to_pair : (CCSexp.t * CCSexp.t) conv
Expect a list of two elements
val to_pair_with : 'a conv ->
'b conv -> ('a * 'b) conv
Same as CCSexp.Traverse.to_pair but applies conversion functions
Since 0.4.1
val to_triple : (CCSexp.t * CCSexp.t * CCSexp.t) conv
val to_triple_with : 'a conv ->
'b conv ->
'c conv -> ('a * 'b * 'c) conv
val get_field : string -> CCSexp.t conv
get_field name e, when e = List [(n1,x1); (n2,x2) ... ], extracts the xi such that name = ni, if it can find it.
val field : string -> 'a conv -> 'a conv
Enriched version of CCSexp.Traverse.get_field, with a converter as argument
val get_variant : (string * (CCSexp.t list -> 'a option)) list -> 'a conv
get_variant l e checks whether e = List (Atom s :: args), and if some pair of l is s, f. In this case, it calls f args and returns its result, otherwise it returns None.
val field_list : string -> (CCSexp.t list -> 'a option) -> 'a conv
field_list name f "(... (name a b c d) ...record)" will look for a field based on the given name, and expect it to have a list of arguments dealt with by f (here, "a b c d").
Since 0.4.1
val (>>=) : 'a option -> ('a -> 'b option) -> 'b option
val (>|=) : 'a option -> ('a -> 'b) -> 'b option
val return : 'a -> 'a option
val get_exn : 'a option -> 'a
Unwrap an option, possibly failing.
Raises Invalid_argument if the argument is None