Module SkhcQuery.QuerySource

Operations on queries

Sourcetype 'a t =
  1. | Node of 'a
  2. | And of 'a t * 'a t
  3. | Or of 'a t * 'a t
  4. | Not of 'a t

type of queries

Sourceval node : 'a -> 'a t

node n builds a query node with n.

Sourceval (land) : 'a t -> 'a t -> 'a t

(land) lhs rhs builds an `and` node between lhs and rhs.

Sourceval (lor) : 'a t -> 'a t -> 'a t

(lor) lhs rhs builds an `or` node between lhs and rhs.

Sourceval lnot : 'a t -> 'a t

lnot query builds the negation of query.

Sourceval verum : Node.t t

verum is a query that always matches when used with matches_* functions.

Sourceval always : Node.t t

always is verum.

Sourceval falsum : Node.t t

falsum is a query that never matches when used with matches_* functions

Sourceval never : Node.t t

never is falsum.

Sourceval union : 'a t -> 'a t -> 'a t

union q1 q2 builds a query that matches either q1 or q2.

Sourceval diff : 'a t -> 'a t -> 'a t

diff q1 q2 builds a query that matches q1 minus elements matched by q2.

Sourceval equal : 'a t -> 'a t -> bool

equal lhs rhs tests whether lhs and rhs are structurally equal, not semantically. In particular, two queries matching the same elements but are structurally different will return false.

Sourceval to_string_f : ('a -> string) -> 'a t -> string

to_string_f f query is a string representation of query using f.

  • since 0.3.0
Sourceval to_string : Node.t t -> string

to_string query is a string representation of query.

Sourceval to_sexp_f : ('a -> string) -> 'a t -> string

to_sexp query is a s-expression representation of query using f.

  • since 0.3.0
Sourceval to_sexp : Node.t t -> string

to_sexp query is a s-expression representation of query. In particular, of_sexp (to_sexp query) = Some query.

Sourceval to_sexp_keys : (_, _, _, _, _) Field.t t -> string

to_sexp_keys query

  • since 0.3.0
Sourceval of_string_keys : string -> Field.String.Key.t list option

of_string_keys s tries to parse s as whitespace separeted string of key string. Returns None if of_string_keys fails to parse s.

  • since 0.3.0
Sourceval of_sexp : string -> Node.t t option

of_sexp sexp tries to parse sexp. Returns None if of_sexp fails to parse sexp.

Sourceval of_sexp_keys : string -> (unit, unit, unit, unit, unit) Field.t t option

of_sexp sexp tries to parse sexp as an S-expression of Field.t. Returns None if of_sexp fails to parse sexp.

  • since 0.3.0
Sourceval of_strings : string list -> Node.t t option

of_strings args tries to parse args to create a query. Returns None if of_strings fails to parse sexp.

Sourceval matches : ('a -> bool) -> 'a t -> bool

matches f query tests whether query matches according to the predicate f on a node.

matches_musics substrings music album participants properties query populates fields with music, album, participants and properties and tests whether query matches.

matches_albums substrings album stats participants query populates fields with album, stats and participants and tests whether query matches.

Sourceval matches_artists : Field.String.Key.t list -> SkhcDb.Artist.t -> Node.t t -> bool

matches_artists substrings artist query populates fields with artist and tests whether query matches.

Sourceval matches_metadata_subset : SkhcMetadata.Metadata.t -> SkhcMetadata.Metadata.t -> (_, _, _, _, _) Field.t t -> bool

matches_metadata_subset m1 m2 query compares fields between m1 and m2 according to query. For field returning multitple values such as artist, return true if m1 is a subset of m2.

  • since 0.3.0