Using Matcha
Setting up
The latest version of Matcha
can be installed in scripts or iex
via:
Mix.install([{:matcha, github: "christhekeele/matcha", tag: "stable"}], force: true)
IO.puts("Installed matcha version: #{Application.spec(:matcha, :vsn)}")
The primary entrypoint to Matcha concepts are the macros in the Matcha
module,
so we require it to make them available:
require Matcha
Matcha.__info__(:macros)
Functionality Overview
As the macros list suggests, Matcha provides easy ways to:
-
Create match patterns
Matcha.Pattern
functions can then be used to find data matching them. -
Create match filters
Matcha.Filter
functions can then be used to filter data with them. -
Create match specifications
Matcha.Spec
functions can then be used to select and transform data with them. -
Trace activity in the current runtime
Matcha.Trace
functions can be used to further interact with the tracing engine.
Let’s play with each in turn.
Match Patterns
spec =
Matcha.spec do
{x, y, z} -> {x, y, z}
end