DeepDive.Comparer (Deep Dive v1.0.0) View Source

This module holds the logic to match the keys in a data structure.

Link to this section Summary

Types

A fuzzy_matcher is one that may return upon match more than one result.

A matcher is any type that may be compared to a key. There are two special cases

Functions

This function retrieves all the matches of matcher. The return value is a list of the key-value tuples.

This function retrieves the first match of matcher and the corresponting matching key. In case of no match, it returns nil.

Link to this section Types

Specs

fuzzy_matcher() :: Regex.t() | (term() -> bool())

A fuzzy_matcher is one that may return upon match more than one result.

Specs

matcher() ::
  char()
  | String.t()
  | atom()
  | list()
  | map()
  | struct()
  | pid()
  | fuzzy_matcher()

A matcher is any type that may be compared to a key. There are two special cases:

  • A Regex, is compared with =~.
  • A function of kind term -> bool, is applied to the key to verify the match.
  • Anything else is matched via ==.

Link to this section Functions

Specs

get_all_keys(map(), matcher()) :: DeepDive.result()

This function retrieves all the matches of matcher. The return value is a list of the key-value tuples.

Note also that this function operates only at the first level and does not steps into the key values.

Specs

get_key(map(), matcher()) :: {term(), term()} | nil

This function retrieves the first match of matcher and the corresponting matching key. In case of no match, it returns nil.