Hyperlinkv0.8.0-beta.28

Match

Match.Notinterfaceeffect/Match.ts:231
Not

Represents a negative pattern matching case.

Details

A Not case contains the logic to test if a value does NOT match a specific pattern and the function to evaluate when the pattern doesn't match. It's used for exclusion-based pattern matching.

Example (Creating negative match cases)

import { Match } from "effect"

// Not creates cases that exclude specific patterns
const matcher = Match.type<string>().pipe(
  // Match any string except "forbidden"
  Match.not("forbidden", (s) => `Allowed: ${s}`),
  Match.orElse(() => "This string is forbidden")
)

console.log(matcher("hello")) // "Allowed: hello"
console.log(matcher("forbidden")) // "This string is forbidden"
models
Source effect/Match.ts:2315 lines
export interface Not {
  readonly _tag: "Not"
  guard(u: unknown): boolean
  evaluate(input: unknown): any
}
Referenced by 1 symbols