Skip to content

Patternia v0.8.5 Release Note

Release Date: March 10, 2026 Version: 0.8.5


Overview

Patternia v0.8.5 was an API modernization release focused on explicit binding, variant pattern naming, and guarded structural validation.

This page has been normalized to the current API surface. The original release note mixed these changes with chained examples and older namespace-qualified variant names.


Highlights

Variant Pattern Naming

Type-based variant matching uses the short public forms:

  • is<T>() for type-based dispatch
  • alt<I>() for index-based dispatch
  • $(is<T>()) when the matched alternative must be bound
using namespace ptn;

std::string describe(const std::variant<int, std::string> &value) {
  return match(value) | on(
    is<int>() >> "int",
    $(is<std::string>()) >> [](const std::string &text) {
      return "str:" + text;
    },
    _ >> [] { return std::string("other"); }
  );
}

Callable $() Binding

The binding shorthand is uniform across literal, structural, and variant patterns.

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
  );
}

Structural Validation Without Binding

Structural patterns can be guarded directly when a handler only needs a yes or no decision.

using namespace ptn;

bool balanced(const Point &point) {
  return match(point) | on(
    has<&Point::x, &Point::y>()[arg<0> + arg<1> == 0] >> true,
    _ >> false
  );
}

Migration Notes

  • Older namespace-qualified variant spellings have been retired in favor of is<T>() and alt<I>().
  • Binding a selected variant alternative should use $(is<T>()).
  • Binding structural members should use $(has<...>()) or bind(has<...>()).

Historical Note

The original v0.8.5 note introduced the same direction through a mixture of chained examples and older variant naming. Current code should use pipeline matching exclusively.