effect-io-ai

Package: effect
Module: Predicate

Predicate.isTagged

Checks whether a value has a _tag property equal to the given tag.

When to use

Use when you model tagged unions with a _tag field and want a quick Predicate guard for tagged values.

Details

Uses hasProperty and strict equality on _tag.

Example (Guarding tagged values)

import { Predicate } from "effect"

const isOk = Predicate.isTagged("Ok")

console.log(isOk({ _tag: "Ok", value: 1 }))

See

Signature

declare const isTagged: { <K extends string>(tag: K): (self: unknown) => self is { _tag: K; }; <K extends string>(self: unknown, tag: K): self is { _tag: K; }; }

Source

Since v2.0.0