export interface Left { readonly _either: 'Left'; readonly left: L; } export interface Right { readonly _either: 'Right'; readonly right: R; } /** * Represents a value of one of two possible types (a disjoint union). * * An instance of {@linkcode Either} is either an instance of {@linkcode Left} or {@linkcode Right}. * * A common use of {@linkcode Either} is as an alternative to `Optional` for dealing with possible missing values. In this usage, * `Optional.empty` is replaced with a {@linkcode Left}, which can contain useful information. {@linkcode Right} takes the place of `Optional.map`. * Convention dictates that {@linkcode Left} is used for failure and {@linkcode Right} is used for success. * * For example, `Either` could be used to detect whether a received input has the expected `number` type. * If it doesn't, an `Error` is returned. * * ```typescript * import { Either, left, right } from 'rimo' * * const parse = (input: string): Either => { * const n = parseInt(input, 10) * return isNaN(n) ? left(new Error('not a number')) : right(n) * } * ``` */ export declare type Either = Left | Right; /** * Constructs a new `Either` holding a `Left` value. This usually represents a failure. */ export declare const left: (left: L) => Either; /** * Constructs a new `Either` holding a `Right` value. This usually represents a successful value. */ export declare const right: (right: R) => Either; export declare const isLeft: (ma: Either) => ma is Left; export declare const isRight: (ma: Either) => ma is Right;