First-class match specifications for Elixir.
š | Test Suite | Test Coverage |
---|---|---|
Release | ||
Latest |
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.
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.
# 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!
Check out the interactive usage guides, including using Matcha for:
Complete documentation, including guides, are hosted online on hexdocs.pm.
Contributions are welcome! Check out the contributing guide for more information, and suggestions on where to start.
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:
- Elixir 1.14.x
- OTP 23.x
- OTP 24.x
- OTP 25.x
- Elixir 1.15.x
- OTP 24.x
- OTP 25.x
- OTP 26.x
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:
- Elixir 1.10.x
- OTP 21.x
- OTP 22.x
- OTP 23.x
- Elixir 1.11.x
- OTP 21.x
- OTP 22.x
- OTP 23.x
- OTP 24.x
- Elixir 1.12.x
- OTP 22.x
- OTP 23.x
- OTP 24.x
- Elixir 1.13.x
- OTP 22.x
- OTP 23.x
- OTP 24.x
- OTP 25.x
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.