© 2026 Hedgehog Software, LLC
Match
Effect.Effect<unknown, unknown, unknown>
class ProductStatus extends Schema.TaggedClass<ProductStatus>()("ProductStatus", { status: Schema.literal("inactive", "active"), cancelledAt: Schema.nullable(Schema.DateFromSelf), }){} class SomeSchemaTaggedError extends Schema.TaggedError<SomeSchemaTaggedError>()("SomeSchemaTaggedError", {}){} class SomeDataTaggedError extends Data.TaggedClass('SomeDataTaggedError')<{ }> {} //: Effect.Effect<unknown, unknown, unknown> | ProductStatus | SomeDataTaggedError //Expected: SomeDataTaggedError | SomeSchemaTaggedError | ProductStatus const op = pipe( Match.value(new ProductStatus({status: "active", cancelledAt: null})), Match.not( { status: "active" }, (_) => new SomeDataTaggedError() ), Match.when( { cancelledAt: Match.instanceOf(Date) }, (_) => new SomeSchemaTaggedError() ), Match.orElse( (ps) => new ProductStatus({ ...ps, status: "inactive", cancelledAt: new Date(), }) ) );