/** * ```ts * type Option = None | Some * ``` * * `Option` is a container for an optional value of type `A`. If the value of type `A` is present, the `Option` is * an instance of `Some`, containing the present value of type `A`. If the value is absent, the `Option` is an * instance of `None`. * * An option could be looked at as a collection or foldable structure with either one or zero elements. * Another way to look at `Option` is: it represents the effect of a possibly failing computation. * * * @example * import * as O from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * const double = (n: number): number => n * 2 * * export const imperative = (as: ReadonlyArray): string => { * const head = (as: ReadonlyArray): number => { * if (as.length === 0) { * throw new Error() * } * return as[0] * } * const inverse = (n: number): number => { * if (n === 0) { * throw new Error() * } * return 1 / n * } * try { * return `Result is ${inverse(double(head(as)))}` * } catch (e) { * return 'no result' * } * } * * export const functional = (as: ReadonlyArray): string => { * const head = (as: ReadonlyArray): O.Option => * as.length === 0 ? O.none : O.some(as[0]) * const inverse = (n: number): O.Option => * n === 0 ? O.none : O.some(1 / n) * return pipe( * as, * head, * O.map(double), * O.chain(inverse), * O.match( * () => 'no result', // onNone handler * (head) => `Result is ${head}` // onSome handler * ) * ) * } * * assert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3])) * assert.deepStrictEqual(imperative([]), functional([])) * assert.deepStrictEqual(imperative([0]), functional([0])) * * @since 2.0.0 */ import { Alt1 } from './Alt' import { Alternative1 } from './Alternative' import { Applicative1 } from './Applicative' import { Apply1 } from './Apply' import { Chain1 } from './Chain' import { Compactable1 } from './Compactable' import { Either } from './Either' import { Eq } from './Eq' import { Extend1 } from './Extend' import { Filterable1 } from './Filterable' import { Foldable1 } from './Foldable' import { FromEither1 } from './FromEither' import { Lazy } from './function' import { Functor1 } from './Functor' import { Monad1 } from './Monad' import { MonadThrow1 } from './MonadThrow' import { Monoid } from './Monoid' import { Ord } from './Ord' import { Pointed1 } from './Pointed' import { Predicate } from './Predicate' import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray' import { Refinement } from './Refinement' import { Semigroup } from './Semigroup' import { Separated } from './Separated' import { Show } from './Show' import { PipeableTraverse1, Traversable1 } from './Traversable' import { PipeableWilt1, PipeableWither1, Witherable1 } from './Witherable' import { Zero1 } from './Zero' /** * @category model * @since 2.0.0 */ export interface None { readonly _tag: 'None' } /** * @category model * @since 2.0.0 */ export interface Some { readonly _tag: 'Some' readonly value: A } /** * @category model * @since 2.0.0 */ export declare type Option = None | Some /** * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value. * * @category constructors * @since 2.0.0 */ export declare const none: Option /** * Constructs a `Some`. Represents an optional value that exists. * * @category constructors * @since 2.0.0 */ export declare const some: (a: A) => Option /** * Returns a *smart constructor* based on the given predicate. * * @example * import { none, some, fromPredicate } from 'fp-ts/Option' * * const getOption = fromPredicate((n: number) => n >= 0) * * assert.deepStrictEqual(getOption(-1), none) * assert.deepStrictEqual(getOption(1), some(1)) * * @category lifting * @since 2.0.0 */ export declare function fromPredicate(refinement: Refinement): (a: A) => Option export declare function fromPredicate(predicate: Predicate): (b: B) => Option export declare function fromPredicate(predicate: Predicate): (a: A) => Option /** * Returns the `Left` value of an `Either` if possible. * * @example * import { getLeft, none, some } from 'fp-ts/Option' * import { right, left } from 'fp-ts/Either' * * assert.deepStrictEqual(getLeft(right(1)), none) * assert.deepStrictEqual(getLeft(left('a')), some('a')) * * @category constructors * @since 2.0.0 */ export declare const getLeft: (ma: Either) => Option /** * Returns the `Right` value of an `Either` if possible. * * @example * import { getRight, none, some } from 'fp-ts/Option' * import { right, left } from 'fp-ts/Either' * * assert.deepStrictEqual(getRight(right(1)), some(1)) * assert.deepStrictEqual(getRight(left('a')), none) * * @category constructors * @since 2.0.0 */ export declare const getRight: (ma: Either) => Option /** * @category type lambdas * @since 2.0.0 */ export declare const URI = 'Option' /** * @category type lambdas * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind { readonly [URI]: Option } } /** * @category instances * @since 2.0.0 */ export declare const getShow: (S: Show) => Show> /** * @example * import { none, some, getEq } from 'fp-ts/Option' * import * as N from 'fp-ts/number' * * const E = getEq(N.Eq) * assert.strictEqual(E.equals(none, none), true) * assert.strictEqual(E.equals(none, some(1)), false) * assert.strictEqual(E.equals(some(1), none), false) * assert.strictEqual(E.equals(some(1), some(2)), false) * assert.strictEqual(E.equals(some(1), some(1)), true) * * @category instances * @since 2.0.0 */ export declare const getEq: (E: Eq) => Eq> /** * The `Ord` instance allows `Option` values to be compared with * `compare`, whenever there is an `Ord` instance for * the type the `Option` contains. * * `None` is considered to be less than any `Some` value. * * * @example * import { none, some, getOrd } from 'fp-ts/Option' * import * as N from 'fp-ts/number' * * const O = getOrd(N.Ord) * assert.strictEqual(O.compare(none, none), 0) * assert.strictEqual(O.compare(none, some(1)), -1) * assert.strictEqual(O.compare(some(1), none), 1) * assert.strictEqual(O.compare(some(1), some(2)), -1) * assert.strictEqual(O.compare(some(1), some(1)), 0) * * @category instances * @since 2.0.0 */ export declare const getOrd: (O: Ord) => Ord> /** * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are * concatenated using the provided `Semigroup` * * | x | y | concat(x, y) | * | ------- | ------- | ------------------ | * | none | none | none | * | some(a) | none | some(a) | * | none | some(b) | some(b) | * | some(a) | some(b) | some(concat(a, b)) | * * @example * import { getMonoid, some, none } from 'fp-ts/Option' * import { SemigroupSum } from 'fp-ts/number' * * const M = getMonoid(SemigroupSum) * assert.deepStrictEqual(M.concat(none, none), none) * assert.deepStrictEqual(M.concat(some(1), none), some(1)) * assert.deepStrictEqual(M.concat(none, some(1)), some(1)) * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3)) * * @category instances * @since 2.0.0 */ export declare const getMonoid: (S: Semigroup) => Monoid> /** * @category mapping * @since 2.0.0 */ export declare const map: (f: (a: A) => B) => (fa: Option) => Option /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor1 /** * @category constructors * @since 2.7.0 */ export declare const of: (a: A) => Option /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed1 /** * @since 2.0.0 */ export declare const ap: (fa: Option) => (fab: Option<(a: A) => B>) => Option /** * @category instances * @since 2.10.0 */ export declare const Apply: Apply1 /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative1 /** * Composes computations in sequence, using the return value of one computation to determine the next computation. * * @category sequencing * @since 2.0.0 */ export declare const chain: (f: (a: A) => Option) => (ma: Option) => Option /** * @category instances * @since 2.10.0 */ export declare const Chain: Chain1 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad1 /** * @category folding * @since 2.0.0 */ export declare const reduce: (b: B, f: (b: B, a: A) => B) => (fa: Option) => B /** * @category folding * @since 2.0.0 */ export declare const foldMap: (M: Monoid) => (f: (a: A) => M) => (fa: Option) => M /** * @category folding * @since 2.0.0 */ export declare const reduceRight: (b: B, f: (a: A, b: B) => B) => (fa: Option) => B /** * @category instances * @since 2.7.0 */ export declare const Foldable: Foldable1 /** * Less strict version of [`alt`](#alt). * * The `W` suffix (short for **W**idening) means that the return types will be merged. * * @category error handling * @since 2.9.0 */ export declare const altW: (that: Lazy>) => (fa: Option) => Option /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * * In case of `Option` returns the left-most non-`None` value. * * | x | y | pipe(x, alt(() => y) | * | ------- | ------- | -------------------- | * | none | none | none | * | some(a) | none | some(a) | * | none | some(b) | some(b) | * | some(a) | some(b) | some(a) | * * @example * import * as O from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.deepStrictEqual( * pipe( * O.none, * O.alt(() => O.none) * ), * O.none * ) * assert.deepStrictEqual( * pipe( * O.some('a'), * O.alt(() => O.none) * ), * O.some('a') * ) * assert.deepStrictEqual( * pipe( * O.none, * O.alt(() => O.some('b')) * ), * O.some('b') * ) * assert.deepStrictEqual( * pipe( * O.some('a'), * O.alt(() => O.some('b')) * ), * O.some('a') * ) * * @category error handling * @since 2.0.0 */ export declare const alt: (that: Lazy>) => (fa: Option) => Option /** * @category instances * @since 2.7.0 */ export declare const Alt: Alt1 /** * @since 2.7.0 */ export declare const zero: () => Option /** * @category instances * @since 2.11.0 */ export declare const Zero: Zero1 /** * @category do notation * @since 2.11.0 */ export declare const guard: (b: boolean) => Option /** * @category instances * @since 2.7.0 */ export declare const Alternative: Alternative1 /** * @since 2.0.0 */ export declare const extend: (f: (wa: Option) => B) => (wa: Option) => Option /** * @category instances * @since 2.7.0 */ export declare const Extend: Extend1 /** * @category filtering * @since 2.0.0 */ export declare const compact: (fa: Option>) => Option /** * @category filtering * @since 2.0.0 */ export declare const separate: (ma: Option>) => Separated, Option> /** * @category instances * @since 2.7.0 */ export declare const Compactable: Compactable1 /** * @category filtering * @since 2.0.0 */ export declare const filter: { (refinement: Refinement): (fa: Option) => Option (predicate: Predicate): (fb: Option) => Option (predicate: Predicate): (fa: Option) => Option } /** * @category filtering * @since 2.0.0 */ export declare const filterMap: (f: (a: A) => Option) => (fa: Option) => Option /** * @category filtering * @since 2.0.0 */ export declare const partition: { (refinement: Refinement): (fa: Option) => Separated, Option> (predicate: Predicate): (fb: Option) => Separated, Option> (predicate: Predicate): (fa: Option) => Separated, Option> } /** * @category filtering * @since 2.0.0 */ export declare const partitionMap: ( f: (a: A) => Either ) => (fa: Option) => Separated, Option> /** * @category instances * @since 2.7.0 */ export declare const Filterable: Filterable1 /** * @category traversing * @since 2.6.3 */ export declare const traverse: PipeableTraverse1 /** * @category traversing * @since 2.6.3 */ export declare const sequence: Traversable1['sequence'] /** * @category instances * @since 2.7.0 */ export declare const Traversable: Traversable1 /** * @category filtering * @since 2.6.5 */ export declare const wither: PipeableWither1 /** * @category filtering * @since 2.6.5 */ export declare const wilt: PipeableWilt1 /** * @category instances * @since 2.7.0 */ export declare const Witherable: Witherable1 /** * @since 2.7.0 */ export declare const throwError: MonadThrow1['throwError'] /** * @category instances * @since 2.7.0 */ export declare const MonadThrow: MonadThrow1 /** * Transforms an `Either` to an `Option` discarding the error. * * Alias of [getRight](#getright) * * @category conversions * @since 2.0.0 */ export declare const fromEither: (fa: Either) => Option /** * @category instances * @since 2.11.0 */ export declare const FromEither: FromEither1 /** * Returns `true` if the option is an instance of `Some`, `false` otherwise. * * @example * import { some, none, isSome } from 'fp-ts/Option' * * assert.strictEqual(isSome(some(1)), true) * assert.strictEqual(isSome(none), false) * * @category refinements * @since 2.0.0 */ export declare const isSome: (fa: Option) => fa is Some /** * Returns `true` if the option is `None`, `false` otherwise. * * @example * import { some, none, isNone } from 'fp-ts/Option' * * assert.strictEqual(isNone(some(1)), false) * assert.strictEqual(isNone(none), true) * * @category refinements * @since 2.0.0 */ export declare const isNone: (fa: Option) => fa is None /** * Less strict version of [`match`](#match). * * The `W` suffix (short for **W**idening) means that the handler return types will be merged. * * @category pattern matching * @since 2.10.0 */ export declare const matchW: (onNone: Lazy, onSome: (a: A) => C) => (ma: Option) => B | C /** * Alias of [`matchW`](#matchw). * * @category pattern matching * @since 2.10.0 */ export declare const foldW: (onNone: Lazy, onSome: (a: A) => C) => (ma: Option) => B | C /** * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is * returned, otherwise the function is applied to the value inside the `Some` and the result is returned. * * @example * import { some, none, match } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.strictEqual( * pipe( * some(1), * match(() => 'a none', a => `a some containing ${a}`) * ), * 'a some containing 1' * ) * * assert.strictEqual( * pipe( * none, * match(() => 'a none', a => `a some containing ${a}`) * ), * 'a none' * ) * * @category pattern matching * @since 2.10.0 */ export declare const match: (onNone: Lazy, onSome: (a: A) => B) => (ma: Option) => B /** * Alias of [`match`](#match). * * @category pattern matching * @since 2.0.0 */ export declare const fold: (onNone: Lazy, onSome: (a: A) => B) => (ma: Option) => B /** * Less strict version of [`getOrElse`](#getorelse). * * The `W` suffix (short for **W**idening) means that the handler return type will be merged. * * @category error handling * @since 2.6.0 */ export declare const getOrElseW: (onNone: Lazy) => (ma: Option) => B | A /** * Extracts the value out of the structure, if it exists. Otherwise returns the given default value * * @example * import { some, none, getOrElse } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.strictEqual( * pipe( * some(1), * getOrElse(() => 0) * ), * 1 * ) * assert.strictEqual( * pipe( * none, * getOrElse(() => 0) * ), * 0 * ) * * @category error handling * @since 2.0.0 */ export declare const getOrElse: (onNone: Lazy) => (ma: Option) => A /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: Option<(a: A) => B>) => Option /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: (second: Option) => (first: Option) => Option /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: (second: Option) => (first: Option) => Option /** * @category sequencing * @since 2.0.0 */ export declare const flatten: (mma: Option>) => Option /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @category sequencing * @since 2.0.0 */ export declare const chainFirst: (f: (a: A) => Option) => (first: Option) => Option /** * @since 2.0.0 */ export declare const duplicate: (ma: Option) => Option> /** * @category lifting * @since 2.11.0 */ export declare const fromEitherK: , B>( f: (...a: A) => Either ) => (...a: A) => Option /** * @category sequencing * @since 2.11.0 */ export declare const chainEitherK: (f: (a: A) => Either) => (ma: Option) => Option /** * @category sequencing * @since 2.12.0 */ export declare const chainFirstEitherK: (f: (a: A) => Either) => (ma: Option) => Option /** * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise * returns the value wrapped in a `Some`. * * @example * import { none, some, fromNullable } from 'fp-ts/Option' * * assert.deepStrictEqual(fromNullable(undefined), none) * assert.deepStrictEqual(fromNullable(null), none) * assert.deepStrictEqual(fromNullable(1), some(1)) * * @category conversions * @since 2.0.0 */ export declare const fromNullable: (a: A) => Option> /** * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a * `Some`. * * See also [`tryCatchK`](#trycatchk). * * @example * import { none, some, tryCatch } from 'fp-ts/Option' * * assert.deepStrictEqual( * tryCatch(() => { * throw new Error() * }), * none * ) * assert.deepStrictEqual(tryCatch(() => 1), some(1)) * * @category interop * @since 2.0.0 */ export declare const tryCatch: (f: Lazy) => Option /** * Converts a function that may throw to one returning a `Option`. * * @category interop * @since 2.10.0 */ export declare const tryCatchK: (f: (...a: A) => B) => (...a: A) => Option /** * Returns a *smart constructor* from a function that returns a nullable value. * * @example * import { fromNullableK, none, some } from 'fp-ts/Option' * * const f = (s: string): number | undefined => { * const n = parseFloat(s) * return isNaN(n) ? undefined : n * } * * const g = fromNullableK(f) * * assert.deepStrictEqual(g('1'), some(1)) * assert.deepStrictEqual(g('a'), none) * * @category lifting * @since 2.9.0 */ export declare const fromNullableK: , B>( f: (...a: A) => B | null | undefined ) => (...a: A) => Option> /** * This is `chain` + `fromNullable`, useful when working with optional values. * * @example * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * interface Employee { * readonly company?: { * readonly address?: { * readonly street?: { * readonly name?: string * } * } * } * } * * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } } * * assert.deepStrictEqual( * pipe( * fromNullable(employee1.company), * chainNullableK(company => company.address), * chainNullableK(address => address.street), * chainNullableK(street => street.name) * ), * some('high street') * ) * * const employee2: Employee = { company: { address: { street: {} } } } * * assert.deepStrictEqual( * pipe( * fromNullable(employee2.company), * chainNullableK(company => company.address), * chainNullableK(address => address.street), * chainNullableK(street => street.name) * ), * none * ) * * @category sequencing * @since 2.9.0 */ export declare const chainNullableK: ( f: (a: A) => B | null | undefined ) => (ma: Option) => Option> /** * Extracts the value out of the structure, if it exists. Otherwise returns `null`. * * @example * import { some, none, toNullable } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.strictEqual( * pipe( * some(1), * toNullable * ), * 1 * ) * assert.strictEqual( * pipe( * none, * toNullable * ), * null * ) * * @category conversions * @since 2.0.0 */ export declare const toNullable: (ma: Option) => A | null /** * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`. * * @example * import { some, none, toUndefined } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.strictEqual( * pipe( * some(1), * toUndefined * ), * 1 * ) * assert.strictEqual( * pipe( * none, * toUndefined * ), * undefined * ) * * @category conversions * @since 2.0.0 */ export declare const toUndefined: (ma: Option) => A | undefined /** * Returns `true` if `ma` contains `a` * * @example * import { some, none, elem } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * import * as N from 'fp-ts/number' * * assert.strictEqual(pipe(some(1), elem(N.Eq)(1)), true) * assert.strictEqual(pipe(some(1), elem(N.Eq)(2)), false) * assert.strictEqual(pipe(none, elem(N.Eq)(1)), false) * * @since 2.0.0 */ export declare function elem(E: Eq): { (a: A): (ma: Option) => boolean (a: A, ma: Option): boolean } /** * Returns `true` if the predicate is satisfied by the wrapped value * * @example * import { some, none, exists } from 'fp-ts/Option' * import { pipe } from 'fp-ts/function' * * assert.strictEqual( * pipe( * some(1), * exists(n => n > 0) * ), * true * ) * assert.strictEqual( * pipe( * some(1), * exists(n => n > 1) * ), * false * ) * assert.strictEqual( * pipe( * none, * exists(n => n > 0) * ), * false * ) * * @since 2.0.0 */ export declare const exists: (predicate: Predicate) => (ma: Option) => boolean /** * @category do notation * @since 2.9.0 */ export declare const Do: Option<{}> /** * @category do notation * @since 2.8.0 */ export declare const bindTo: (name: N) => (fa: Option) => Option<{ readonly [K in N]: A }> declare const let_: ( name: Exclude, f: (a: A) => B ) => (fa: Option) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> export { /** * @category do notation * @since 2.13.0 */ let_ as let } /** * @category do notation * @since 2.8.0 */ export declare const bind: ( name: Exclude, f: (a: A) => Option ) => (ma: Option) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @category do notation * @since 2.8.0 */ export declare const apS: ( name: Exclude, fb: Option ) => (fa: Option) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @since 2.11.0 */ export declare const ApT: Option /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: ( f: (index: number, a: A) => Option ) => (as: ReadonlyNonEmptyArray) => Option> /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: ( f: (index: number, a: A) => Option ) => (as: readonly A[]) => Option /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => Option ) => (as: ReadonlyArray) => Option> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: (f: (a: A) => Option) => (as: readonly A[]) => Option /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => Option> /** * Use `Refinement` module instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function getRefinement(getOption: (a: A) => Option): Refinement /** * Use [`chainNullableK`](#chainnullablek) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const mapNullable: (f: (a: A) => B | null | undefined) => (ma: Option) => Option> /** * This instance is deprecated, use small, specific instances instead. * For example if a function needs a `Functor` instance, pass `O.Functor` instead of `O.option` * (where `O` is from `import O from 'fp-ts/Option'`) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const option: Monad1 & Foldable1 & Alternative1 & Extend1 & Witherable1 & MonadThrow1 /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplySemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplyMonoid: (M: Monoid) => Monoid> /** * Use * * ```ts * import { first } from 'fp-ts/Semigroup' * import { getMonoid } from 'fp-ts/Option' * * getMonoid(first()) * ``` * * instead. * * Monoid returning the left-most non-`None` value * * | x | y | concat(x, y) | * | ------- | ------- | ------------ | * | none | none | none | * | some(a) | none | some(a) | * | none | some(b) | some(b) | * | some(a) | some(b) | some(a) | * * @example * import { getFirstMonoid, some, none } from 'fp-ts/Option' * * const M = getFirstMonoid() * assert.deepStrictEqual(M.concat(none, none), none) * assert.deepStrictEqual(M.concat(some(1), none), some(1)) * assert.deepStrictEqual(M.concat(none, some(2)), some(2)) * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1)) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getFirstMonoid: () => Monoid> /** * Use * * ```ts * import { last } from 'fp-ts/Semigroup' * import { getMonoid } from 'fp-ts/Option' * * getMonoid(last()) * ``` * * instead. * * Monoid returning the right-most non-`None` value * * | x | y | concat(x, y) | * | ------- | ------- | ------------ | * | none | none | none | * | some(a) | none | some(a) | * | none | some(b) | some(b) | * | some(a) | some(b) | some(b) | * * @example * import { getLastMonoid, some, none } from 'fp-ts/Option' * * const M = getLastMonoid() * assert.deepStrictEqual(M.concat(none, none), none) * assert.deepStrictEqual(M.concat(some(1), none), some(1)) * assert.deepStrictEqual(M.concat(none, some(2)), some(2)) * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2)) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getLastMonoid: () => Monoid>