/**
* ```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