/** * represents a simple "present or absent" type. * * This is very similar to existing implementations, e.g. in fp-ts * and differs mostly in that the types are a bit more relaxed. * * @module */ export type Option = Readonly<{ __tag: "some"; value: T; } | { __tag: "none"; }>; export declare const some: (value: T) => Option; export declare const none: Option; export declare const fromNullable: (value: T | undefined | null) => Option; export declare const map: (fn: (value: T) => U) => (option: Option) => Option; export declare const flatMap: (fn: (value: T) => Option) => (option: Option) => Option; export declare const match: (onNone: () => R, onSome: (value: T) => R) => (option: Option) => R; export declare const getOrElse: (fn: () => F) => (option: Option) => T | F; export declare const toUndefined: (option: Option) => T | undefined; export declare const alt: (second: Option) => (first: Option) => Option; /** * attempt to evaluate a function, returns none if evaluation throws */ export declare const attempt: (fn: () => T) => Option;