Home

Awesome

🍵 Matcha

<!-- MODULEDOC BLURB -->

First-class match specifications for Elixir.

<!-- MODULEDOC BLURB -->

Version Documentation License Benchmarks Dependencies Contributors

👍Test SuiteTest Coverage
ReleaseBuild StatusCoverage Status
LatestBuild StatusCoverage Status

Usage

Installation

Matcha is distributed via hex.pm, you can install it with your dependency manager of choice using the config provided on its hex.pm package listing.

<!-- MODULEDOC SNIPPET --> <!-- all hyperlinks in this snippet must be inline, rather than using markdown link references -->

Synopsis

Matcha offers tight integration with Elixir and match specifications.

Match specifications are a BEAM VM feature that can execute de-structuring, pattern matching, and re-structring operations very close-to-the-metal. They can be used to efficiently:

However, they are notoriously difficult to compose and use. Matcha makes this intuitive with ergonomic macros to compose them, and a high-level API with which to use them.

Examples

# Turn Elixir code into a match specification,
#  then use it to filter/map some data
iex> require Matcha
...> Matcha.spec do
...>   {x, y, z} -> x + y + z
...> end
...> |> Matcha.Spec.run!([
...>   {1, 2, 3},
...>   {1, 2},
...>   {1, 2, 3, 4},
...>   {4, 5, 6}
...> ])
[6, 15]

This is one way to run test and develop match specifications, but they truly shine in table and tracing applications!

Guides

Check out the interactive usage guides, including using Matcha for:

<!-- MODULEDOC SNIPPET -->

Documentation

Complete documentation, including guides, are hosted online on hexdocs.pm.

Contributing

Contributions are welcome! Check out the contributing guide for more information, and suggestions on where to start.

Supported Versions

Matcha strives to support the most recent three versions of Elixir and the Erlang/OTPs they support. The canonical list of supported combinations is available by checking the latest successful test matrix run, but boils down to:

Earlier versions of Elixir tend to work well, provided you polyfill Elixir 1.14.0's PartitionSupervisor, back to Elixir 1.10, but the test suite often uses newer syntax that is complicated to circumvent when testing on older versions (ex. range step literals), so we don't officially commit to being compatible with them since they are not a part of the suite. Versions that may work include:

Since Matcha pokes around in compiler internals, it is important to get ahead of upcoming changes to the language. This is accomplished with nightly builds against the latest versions of Elixir, Erlang/OTP, and dependencies; which catches issues like internal compiler function signature changes well in advance of release.

<!-- LINKS & IMAGES --> <!-- Hex --> <!-- Docs --> <!-- Deps --> <!-- Benchmarks --> <!-- Contributors --> <!-- Status --> <!-- Release Status --> <!-- Latest Status --> <!-- Other -->