TypeMatcher<Input, Filters, Remaining, Result, Return>Represents a pattern matcher that operates on types rather than specific values.
Details
A TypeMatcher is created when using Match.type<T>() and allows you to define
patterns that will be applied to values of the specified type. It maintains
type-level information about the input type, applied filters, remaining cases,
and expected results.
Example (Creating a type matcher)
import { Match } from "effect"
// Create a TypeMatcher for string | number
const matcher = Match.type<string | number>().pipe(
Match.when(Match.string, (s) => `String: ${s}`),
Match.when(Match.number, (n) => `Number: ${n}`),
Match.exhaustive
)
console.log(matcher("hello")) // "String: hello"
console.log(matcher(42)) // "Number: 42"export interface interface TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Represents a pattern matcher that operates on types rather than specific values.
Details
A TypeMatcher is created when using Match.type<T>() and allows you to define
patterns that will be applied to values of the specified type. It maintains
type-level information about the input type, applied filters, remaining cases,
and expected results.
Example (Creating a type matcher)
import { Match } from "effect"
// Create a TypeMatcher for string | number
const matcher = Match.type<string | number>().pipe(
Match.when(Match.string, (s) => `String: ${s}`),
Match.when(Match.number, (n) => `Number: ${n}`),
Match.exhaustive
)
console.log(matcher("hello")) // "String: hello"
console.log(matcher(42)) // "Number: 42"
TypeMatcher<in function (type parameter) Input in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Input, out function (type parameter) Filters in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Filters, out function (type parameter) Remaining in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Remaining, out function (type parameter) Result in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Result, out function (type parameter) Return in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Return = any> extends Pipeable {
readonly TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>._tag: "TypeMatcher"_tag: "TypeMatcher"
readonly [const TypeId: "~effect/match/Match/Matcher"TypeId]: {
readonly _input: T.Contravariant<Input>_input: import TT.type Contravariant<A> = (_: A) => voidFunction-type alias encoding contravariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter contravariant in input
position.
Details
Contravariant<A> is assignable to Contravariant<B> when B extends A,
following the supertype direction.
Example (Defining a contravariant phantom type)
import type { Types } from "effect"
interface Consumer<T> {
readonly _phantom: Types.Contravariant<T>
readonly accept: (value: T) => void
}
Namespace for
Contravariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Contravariant.
Contravariant<function (type parameter) Input in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Input>
readonly _filters: T.Covariant<Filters>_filters: import TT.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) Filters in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Filters>
readonly _remaining: T.Covariant<Remaining>_remaining: import TT.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) Remaining in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Remaining>
readonly _result: T.Covariant<Result>_result: import TT.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) Result in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Result>
readonly _return: T.Covariant<Return>_return: import TT.type Covariant<A> = (_: never) => AFunction-type alias encoding covariant variance for a phantom type
parameter.
When to use
Use as a phantom field type to make a type parameter covariant in output
position.
Details
Covariant<A> is assignable to Covariant<B> when A extends B, following
the subtype direction.
Example (Defining a covariant phantom type)
import type { Types } from "effect"
interface Producer<T> {
readonly _phantom: Types.Covariant<T>
readonly get: () => T
}
Namespace for
Covariant
-related utilities.
When to use
Use when referring to type-level helpers nested under Covariant.
Covariant<function (type parameter) Return in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Return>
}
readonly TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.cases: ReadonlyArray<Case>cases: interface ReadonlyArray<T>ReadonlyArray<type Case = When | NotRepresents a single pattern matching case.
When to use
Use as the common public type for code that needs to inspect, store, or pass
either positive or negative pattern matching cases.
Details
A Case can be either a positive match (When) or a negative match (Not).
Cases are the building blocks of pattern matching logic and determine
how values are tested and transformed.
Case>
TypeMatcher<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>add<function (type parameter) I in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>I, function (type parameter) R in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>R, function (type parameter) RA in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>RA, function (type parameter) A in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>A>(_case: Case_case: type Case = When | NotRepresents a single pattern matching case.
When to use
Use as the common public type for code that needs to inspect, store, or pass
either positive or negative pattern matching cases.
Details
A Case can be either a positive match (When) or a negative match (Not).
Cases are the building blocks of pattern matching logic and determine
how values are tested and transformed.
Case): interface TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>Represents a pattern matcher that operates on types rather than specific values.
Details
A TypeMatcher is created when using Match.type<T>() and allows you to define
patterns that will be applied to values of the specified type. It maintains
type-level information about the input type, applied filters, remaining cases,
and expected results.
Example (Creating a type matcher)
import { Match } from "effect"
// Create a TypeMatcher for string | number
const matcher = Match.type<string | number>().pipe(
Match.when(Match.string, (s) => `String: ${s}`),
Match.when(Match.number, (n) => `Number: ${n}`),
Match.exhaustive
)
console.log(matcher("hello")) // "String: hello"
console.log(matcher(42)) // "Number: 42"
TypeMatcher<function (type parameter) I in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>I, function (type parameter) R in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>R, function (type parameter) RA in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>RA, function (type parameter) A in TypeMatcher<in Input, out Filters, out Remaining, out Result, out Return = any>.add<I, R, RA, A>(_case: Case): TypeMatcher<I, R, RA, A>A>
}