import * as Tp from "../Collections/Immutable/Tuple/index.js"; import type { Either } from "../Either/core.js"; import type { Lazy, Predicate, Refinement } from "../Function/core.js"; import * as St from "../Structural/index.js"; import type { HasUnify } from "../Utils/index.js"; /** * Definitions */ export declare class None implements HasUnify { readonly _tag = "None"; [St.equalsSym](that: unknown): boolean; get [St.hashSym](): number; } export declare class Some implements HasUnify { readonly value: A; readonly _tag = "Some"; constructor(value: A); [St.equalsSym](that: unknown): boolean; get [St.hashSym](): number; } export declare type Option = None | Some; /** * Constructs none */ export declare const none: Option; /** * Constructs none */ export declare function emptyOf(): Option; /** * Constructs Some(A) */ export declare function some(a: A): Option; /** * Classic applicative */ export declare function ap_(fab: Option<(a: A) => B>, fa: Option): Option; /** * Classic applicative * * @ets_data_first ap_ */ export declare function ap(fa: Option): (fab: Option<(a: A) => B>) => Option; /** * Zips `Option[A]` and `Option[B]` into `Option[(A, B)]` */ export declare function zip_(fa: Option, fb: Option): Option>; /** * Zips `Option[A]` and `Option[B]` into `Option[(A, B)]` * * @ets_data_first zip_ */ export declare function zip(fb: Option): (fa: Option) => Option>; /** * Apply both and return first * * @ets_data_first zipFirst_ */ export declare function zipFirst(fb: Option): (fa: Option) => Option; /** * Apply both and return first */ export declare function zipFirst_(fa: Option, fb: Option): Option; /** * Apply both and return second * * @ets_data_first zipSecond_ */ export declare function zipSecond(fb: Option): (fa: Option) => Option; /** * Apply both and return second */ export declare function zipSecond_(fa: Option, fb: Option): Option; /** * Builds a new option constructed using the value of self */ export declare function chain_(self: Option, f: (a: A) => Option): Option; /** * Builds a new option constructed using the value of self * * @ets_data_first chain_ */ export declare function chain(f: (a: A) => Option): (self: Option) => Option; /** * Like chain but ignores the constructed outout * * @ets_data_first tap_ */ export declare function tap(f: (a: A) => Option): (ma: Option) => Option; /** * Like chain but ignores the constructed outout */ export declare function tap_(ma: Option, f: (a: A) => Option): Option; /** * Flattens nested options */ export declare function flatten(fa: Option>): Option; /** * Wraps this option into a second one */ export declare function duplicate(ma: Option): Option>; /** * Returns `true` if the predicate is satisfied by the wrapped value * * @ets_data_first exists_ */ export declare function exists(predicate: Predicate): (ma: Option) => boolean; /** * Returns `true` if the predicate is satisfied by the wrapped value */ export declare function exists_(ma: Option, predicate: Predicate): boolean; /** * Apply `Option[A] => B` in case self is some returning `Option[B]` * * @ets_data_first extend_ */ export declare function extend(f: (fa: Option) => B): (self: Option) => Option; /** * Apply `Option[A] => B` in case self is some returning `Option[B]` */ export declare function extend_(self: Option, f: (fa: Option) => B): Option; /** * Takes a 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. * * @ets_data_first fold_ */ export declare function fold(onNone: () => B, onSome: (a: A) => C): (ma: Option) => B | C; /** * Takes a 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. */ export declare function fold_(ma: Option, onNone: () => B, onSome: (a: A) => C): B | C; /** * Constructs `Option[A]` from `Either[E, A]` discarding `E` */ export declare function fromEither(ma: Either): 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` */ export declare function fromNullable(a: A): Option>; /** * Returns a smart constructor based on the given predicate * * @ets_data_first fromPredicate_ */ export declare function fromPredicate(refinement: Refinement): (a: A) => Option; /** * Returns a smart constructor based on the given predicate * * @ets_data_first fromPredicate_ */ export declare function fromPredicate(predicate: Predicate): (a: A) => Option; /** * Returns a smart constructor based on the given predicate */ export declare function fromPredicate_(a: A, refinement: Refinement): Option; /** * Returns a smart constructor based on the given predicate */ export declare function fromPredicate_(a: A, predicate: Predicate): Option; /** * Returns an `E` value if possible */ export declare function getLeft(ma: Either): Option; /** * Extracts the value out of the structure, if it exists. Otherwise returns the given default value * * @ets_data_first getOrElse_ */ export declare function getOrElse(onNone: () => B): (ma: Option) => A | B; /** * Extracts the value out of the structure, if it exists. Otherwise returns the given default value * * @ets_data_first getOrElseS_ */ export declare function getOrElseS(onNone: () => B): (ma: Option) => B; /** * Extracts the value out of the structure, if it exists. Otherwise returns the given default value */ export declare function getOrElse_(ma: Option, onNone: () => B): A | B; /** * Extracts the value out of the structure, if it exists. Otherwise returns the given default value */ export declare function getOrElseS_(ma: Option, onNone: () => A): A; /** * Returns a `Refinement` (i.e. a custom type guard) from a `Option` returning function. * This function ensures that a custom type guard definition is type-safe. */ export declare function getRefinement(getOption: (a: A) => Option): Refinement; /** * Returns an `A` value if possible */ export declare function getRight(ma: Either): Option; /** * Returns `true` if the option is `None`, `false` otherwise */ export declare function isNone(fa: Option): fa is None; /** * Returns `true` if the option is an instance of `Some`, `false` otherwise */ export declare function isSome(fa: Option): fa is Some; /** * Use `A => B` to transform `Option[A]` to `Option[B]` */ export declare function map_(ma: Option, f: (a: A) => B): Option; /** * Use `A => B` to transform `Option[A]` to `Option[B]` * * @ets_data_first map_ */ export declare function map(f: (a: A) => B): (fa: Option) => Option; /** * This is `chain` + `fromNullable`, useful when working with optional values */ export declare function mapNullable(f: (a: A) => B | null | undefined): (ma: Option) => Option; /** * Extracts the value out of the structure, if it exists. Otherwise returns `null`. */ export declare function toNullable(ma: Option): A | null; /** * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`. */ export declare function toUndefined(ma: Option): A | undefined; /** * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in * `Some` */ export declare function tryCatch(f: Lazy): Option; export declare const PartialExceptionTypeId: unique symbol; export declare type PartialExceptionTypeId = typeof PartialExceptionTypeId; export declare class PartialException { readonly _typeId: PartialExceptionTypeId; } /** * Simulates a partial function */ export declare function partial(f: (miss: () => X) => (...args: ARGS) => A): (...args: ARGS) => Option; //# sourceMappingURL=core.d.ts.map