Build a constructor for tagged values sharing a fixed _tag. The returned function stamps the tag over any user-supplied _tag, keeping discriminants trustworthy for hasTag and switch narrowing.
_tag
const loading = tag("Loading") const loaded = tag("Loaded") type State = | ReturnType<typeof loading> | ReturnType<typeof loaded<{ users: User[] }>> const s: State = loaded({ users: [] }) // { _tag: "Loaded", users: [] } Copy
const loading = tag("Loading") const loaded = tag("Loaded") type State = | ReturnType<typeof loading> | ReturnType<typeof loaded<{ users: User[] }>> const s: State = loaded({ users: [] }) // { _tag: "Loaded", users: [] }
Build a constructor for tagged values sharing a fixed
_tag. The returned function stamps the tag over any user-supplied_tag, keeping discriminants trustworthy for hasTag and switch narrowing.