export interface First extends D.Case {
_tag: "First";
readonly first: number;
};
export const First = D.case<First>();
export interface Second extends D.Case {
_tag: "Second";
readonly second: string;
};
export const Second = D.case<Second>();
export type Thing = First | Second;
// TODO can Data.Case give this for free?
export const isFirst: P.Refinement<Thing, First> =
(thing): thing is First =>
pipe(
M.value(thing),
M.tag('First', constTrue),
M.tag('Second', constFalse),
M.exhaustive,
);
export interface First extends D.Case {
_tag: "First";
readonly first: number;
};
export const First = D.case<First>();
export interface Second extends D.Case {
_tag: "Second";
readonly second: string;
};
export const Second = D.case<Second>();
export type Thing = First | Second;
// TODO can Data.Case give this for free?
export const isFirst: P.Refinement<Thing, First> =
(thing): thing is First =>
pipe(
M.value(thing),
M.tag('First', constTrue),
M.tag('Second', constFalse),
M.exhaustive,
);