ReductionBounds.MailboxMatch (ReductionBounds v0.1.0)

Copy Markdown View Source

Ordered patterns and a restricted guard language for supplied mailbox models.

Patterns: :any, :pid, {:literal, reified_term} and recursive :tuple2, :tuple3, :tuple5, :cons patterns. Guards: true, false, {:is_integer, path}, {:integer_le | :integer_ge, path, bound}. Paths use zero-based tuple fields or cons head/tail. No callbacks, arbitrary guards or native receive optimizations are assumed. Attempts count clauses, not machine instructions; the complete finite matching program is retained.

Summary

Types

clause()

@type clause() :: %{
  kind: :reply | :peer_down | :other,
  pattern: term(),
  guard: term()
}

Functions

choose(clauses, term)

evaluate_guard(g, term)

@spec evaluate_guard(term(), ReductionBounds.RpcTerm.t()) :: boolean()

guard?(g)

@spec guard?(term()) :: boolean()

matches?(p, term)

@spec matches?(term(), ReductionBounds.RpcTerm.t()) :: boolean()

pattern?(p)

@spec pattern?(term()) :: boolean()

validate(clauses)

@spec validate(term()) :: :ok | {:error, term()}