# hasexp / combinator.mli

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96``` ```open Sexplib type filter = Sexp.t -> Sexp.t Zlist.t (** Type of filter, which takes an Sexp tree, and returns the stream of subtrees which match with the filter criteria *) (** No recursive basic operators, which check only the top of Sexp *) val none : filter (** returns none *) val keep : filter (** returns the entire tree *) val atom : filter (** returns the tree if it is an Atom *) val list : filter (** return the tree if it is a List *) (** More complicated combinators, which look List childrens *) val children : filter (** returns the children, if the tree is a List. If an Atom, returns none *) (** Combinators *) val (^.) : filter -> filter -> filter (** Composition. [a ^. b] filters an sexp by [b], then the result is filtered by [a]. The result is concatenated. *) val (|||) : filter -> filter -> filter (** [a ||| b] runs [a] and [b] on the same Sexp and returns the appended results *) val with_ : filter -> filter -> filter (** [with_ f g] returns the result of [f] on an Sexp, filtered by [g]. If some of the result are filtered out by [g], i.e. [g res] is null, they are removed from the result of [with_ f g] on the Sexp. *) val without : filter -> filter -> filter (** Opposite of [with_] *) val ( /> ) : filter -> filter -> filter (** [f /> g] is equal to [g ^. children ^. f]. Run [f] then run [g] against the children of the result *) val ( filter -> filter (** [f then_:filter -> else_:filter -> filter (** Conditional [if_ cond ~then_ ~else]: if [cond] returns non-null, return the result of the run of [then_]. Otherwise return the result of the run of [else_] *) val ( |>| ) : filter -> filter -> filter (** Conditional like [a ? b : c] in C. [f |>| g] runs [f] and if the result is non-null returns them. Otherwise it runs [g] and returns [g]'s result. *) val deep : filter -> filter (** Depth search. At [deep f], if some Sexp matches with [f], its children are not searched. *) val deepest : filter -> filter (** Depth search. If some Sexp matches with [f], its parents are not searched. *) (** XML specific combinators *) module Xml : sig val pcdata : filter val tag : filter val tag_named : string -> filter val tag_p : (string -> bool) -> filter val contents : filter val attrs : filter val filter_attrs : (string -> string -> bool) -> filter val filter_map_attrs : (string -> string -> Sexp.t option) -> filter val assoc_attrs : string -> filter val assoc_attrs_conv : string -> (string -> 'a) -> Sexp.t -> 'a module Make : sig val pcdata : string -> Sexp.t val tag : string -> attrs:Sexp.t list -> Sexp.t list -> Sexp.t end end (** Combinators for OCaml value Sexp representaions (?) *) module Caml : sig val string : string -> Sexp.t val record_elt : string -> Sexp.t -> Sexp.t end ```