Skip to content

Patternia v0.6.0 Release Note

Release Date: December 16, 2025 Version: 0.6.0


Overview

Patternia v0.6.0 expanded the expressive range of the matcher with generic handlers, multi-value guards, and direct structural binding.

This historical page has been normalized to the current pipeline API. The original release note used the removed chained builder syntax.


Highlights

Generic Handlers

Handlers can stay generic while still receiving correctly bound values.

using namespace ptn;

struct Matrix {
  int rows;
  int cols;
  std::vector<double> data;
};

std::string describe(const Matrix &matrix) {
  return match(matrix) | on(
    $(has<&Matrix::rows, &Matrix::cols, &Matrix::data>()) >>
        [](auto rows, auto cols, const auto &data) {
          return std::to_string(rows) + "x" + std::to_string(cols) +
                 ":" + std::to_string(data.size());
        },
    _ >> [] { return std::string("invalid"); }
  );
}

Multi-Value Guards

arg<N> made it possible to express relationships between multiple bound values.

using namespace ptn;

struct Rect {
  int width;
  int height;
};

const char *classify(const Rect &rect) {
  return match(rect) | on(
    bind(has<&Rect::width, &Rect::height>())
        [arg<0> == arg<1>] >> "square",
    bind(has<&Rect::width, &Rect::height>())
        [arg<0> > arg<1>] >> "wide",
    _ >> "other"
  );
}

Structural Binding

Binding a structural pattern forwards the selected members directly to the handler.

using namespace ptn;

struct Point {
  int x;
  int y;
};

int sum(const Point &point) {
  return match(point) | on(
    $(has<&Point::x, &Point::y>()) >> [](int x, int y) {
      return x + y;
    },
    _ >> 0
  );
}

What Still Matters

  • Generic lambdas work with Patternia's normal binding rules.
  • arg<N> is the current way to write relationships across bound values.
  • Binding a structural pattern is still the direct route to member extraction.

Historical Note

The original v0.6.0 note documented the same capabilities through the old builder-style entry points. Those have since been removed; use match(subject) | on(...) in current code.