export interface Left { readonly _tag: 'Left' readonly left: E } export interface Right { readonly _tag: 'Right' readonly right: A } export type Either = Left | Right /** * @internal */ export function Left(e: E): Either { return { _tag: 'Left', left: e } } /** * @internal */ export function Right(a: A): Either { return { _tag: 'Right', right: a } } /** * @internal */ export function match_(fa: Either, onLeft: (e: E) => B, onRight: (a: A) => C): B | C { switch (fa._tag) { case 'Left': return onLeft(fa.left) case 'Right': return onRight(fa.right) } } /** * @internal */ export function match(onLeft: (e: E) => B, onRight: (a: A) => C): (fa: Either) => B | C { return (fa) => match_(fa, onLeft, onRight) }