IOOption overview
IOOption<A>
represents a synchronous computation that either yields a value of type A
or nothing.
If you want to represent a synchronous computation that never fails, please see IO
. If you want to represent a synchronous computation that may fail, please see IOEither
.
Added in v2.12.0
Table of contents
- constructors
- conversions
- do notation
- error handling
- filtering
- instances
- lifting
- mapping
- model
- pattern matching
- sequencing
- traversing
- type lambdas
- utils
constructors
none
Signature
export declare const none: IOOption<never>
Added in v2.12.0
of
Signature
export declare const of: <A>(a: A) => IOOption<A>
Added in v2.12.0
some
Signature
export declare const some: <A>(a: A) => IOOption<A>
Added in v2.12.0
conversions
fromEither
Signature
export declare const fromEither: <A>(fa: Either<unknown, A>) => IOOption<A>
Added in v2.12.0
fromIO
Signature
export declare const fromIO: <A>(fa: I.IO<A>) => IOOption<A>
Added in v2.12.0
fromIOEither
Signature
export declare const fromIOEither: <A>(fa: IOEither<unknown, A>) => IOOption<A>
Added in v2.12.0
fromNullable
Signature
export declare const fromNullable: <A>(a: A) => IOOption<NonNullable<A>>
Added in v2.12.0
fromOption
Signature
export declare const fromOption: <A>(fa: O.Option<A>) => IOOption<A>
Added in v2.12.0
toNullable
Signature
export declare const toNullable: <A>(ma: IOOption<A>) => I.IO<A | null>
Added in v2.12.0
toUndefined
Signature
export declare const toUndefined: <A>(ma: IOOption<A>) => I.IO<A | undefined>
Added in v2.12.0
do notation
Do
Signature
export declare const Do: IOOption<{}>
Added in v2.12.0
apS
Signature
export declare const apS: <N, A, B>(
name: Exclude<N, keyof A>,
fb: IOOption<B>
) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.12.0
bind
Signature
export declare const bind: <N, A, B>(
name: Exclude<N, keyof A>,
f: (a: A) => IOOption<B>
) => (ma: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.12.0
bindTo
Signature
export declare const bindTo: <N>(name: N) => <A>(fa: IOOption<A>) => IOOption<{ readonly [K in N]: A }>
Added in v2.12.0
guard
Signature
export declare const guard: (b: boolean) => IOOption<void>
Added in v2.12.0
let
Signature
export declare const let: <N, A, B>(
name: Exclude<N, keyof A>,
f: (a: A) => B
) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.13.0
error handling
alt
Signature
export declare const alt: <A>(second: Lazy<IOOption<A>>) => (first: IOOption<A>) => IOOption<A>
Added in v2.12.0
altW
Less strict version of alt
.
The W
suffix (short for Widening) means that the return types will be merged.
Signature
export declare const altW: <B>(second: Lazy<IOOption<B>>) => <A>(first: IOOption<A>) => IOOption<B | A>
Added in v2.12.0
getOrElse
Signature
export declare const getOrElse: <A>(onNone: Lazy<I.IO<A>>) => (fa: IOOption<A>) => I.IO<A>
Added in v2.12.0
getOrElseW
Less strict version of getOrElse
.
The W
suffix (short for Widening) means that the handler return type will be merged.
Signature
export declare const getOrElseW: <B>(onNone: Lazy<I.IO<B>>) => <A>(ma: IOOption<A>) => I.IO<B | A>
Added in v2.12.0
filtering
compact
Signature
export declare const compact: <A>(fa: IOOption<O.Option<A>>) => IOOption<A>
Added in v2.12.0
filter
Signature
export declare const filter: {
<A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => IOOption<B>
<A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => IOOption<B>
<A>(predicate: Predicate<A>): (fa: IOOption<A>) => IOOption<A>
}
Added in v2.12.0
filterMap
Signature
export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fga: IOOption<A>) => IOOption<B>
Added in v2.12.0
partition
Signature
export declare const partition: {
<A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => Separated<IOOption<A>, IOOption<B>>
<A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => Separated<IOOption<B>, IOOption<B>>
<A>(predicate: Predicate<A>): (fa: IOOption<A>) => Separated<IOOption<A>, IOOption<A>>
}
Added in v2.12.0
partitionMap
Signature
export declare const partitionMap: <A, B, C>(
f: (a: A) => Either<B, C>
) => (fa: IOOption<A>) => Separated<IOOption<B>, IOOption<C>>
Added in v2.12.0
separate
Signature
export declare const separate: <A, B>(fa: IOOption<Either<A, B>>) => Separated<IOOption<A>, IOOption<B>>
Added in v2.12.0
instances
Alt
Signature
export declare const Alt: Alt1<'IOOption'>
Added in v2.12.0
Alternative
Signature
export declare const Alternative: Alternative1<'IOOption'>
Added in v2.12.0
Applicative
Signature
export declare const Applicative: Applicative1<'IOOption'>
Added in v2.12.0
Apply
Signature
export declare const Apply: Apply1<'IOOption'>
Added in v2.12.0
Chain
Signature
export declare const Chain: Chain1<'IOOption'>
Added in v2.12.0
Compactable
Signature
export declare const Compactable: Compactable1<'IOOption'>
Added in v2.12.0
Filterable
Signature
export declare const Filterable: Filterable1<'IOOption'>
Added in v2.12.0
FromEither
Signature
export declare const FromEither: FromEither1<'IOOption'>
Added in v2.12.0
FromIO
Signature
export declare const FromIO: FromIO1<'IOOption'>
Added in v2.12.0
Functor
Signature
export declare const Functor: Functor1<'IOOption'>
Added in v2.12.0
Monad
Signature
export declare const Monad: Monad1<'IOOption'>
Added in v2.12.0
MonadIO
Signature
export declare const MonadIO: MonadIO1<'IOOption'>
Added in v2.12.0
Pointed
Signature
export declare const Pointed: Pointed1<'IOOption'>
Added in v2.12.0
Zero
Signature
export declare const Zero: Zero1<'IOOption'>
Added in v2.12.0
lifting
fromEitherK
Signature
export declare const fromEitherK: <E, A extends readonly unknown[], B>(
f: (...a: A) => Either<E, B>
) => (...a: A) => IOOption<B>
Added in v2.12.0
fromIOK
Signature
export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => I.IO<B>) => (...a: A) => IOOption<B>
Added in v2.12.0
fromNullableK
Signature
export declare const fromNullableK: <A extends readonly unknown[], B>(
f: (...a: A) => B | null | undefined
) => (...a: A) => IOOption<NonNullable<B>>
Added in v2.12.0
fromOptionK
Signature
export declare const fromOptionK: <A extends readonly unknown[], B>(
f: (...a: A) => O.Option<B>
) => (...a: A) => IOOption<B>
Added in v2.12.0
fromPredicate
Signature
export declare const fromPredicate: {
<A, B extends A>(refinement: Refinement<A, B>): (a: A) => IOOption<B>
<A>(predicate: Predicate<A>): <B extends A>(b: B) => IOOption<B>
<A>(predicate: Predicate<A>): (a: A) => IOOption<A>
}
Added in v2.12.0
mapping
flap
Signature
export declare const flap: <A>(a: A) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>
Added in v2.12.0
map
map
can be used to turn functions (a: A) => B
into functions (fa: F<A>) => F<B>
whose argument and return types use the type constructor F
to represent some computational context.
Signature
export declare const map: <A, B>(f: (a: A) => B) => (fa: IOOption<A>) => IOOption<B>
Added in v2.12.0
model
IOOption (interface)
Signature
export interface IOOption<A> extends IO<Option<A>> {}
Added in v2.12.0
pattern matching
fold
Alias of matchE
.
Signature
export declare const fold: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>
Added in v2.12.0
match
Signature
export declare const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: IOOption<A>) => I.IO<B>
Added in v2.12.0
matchE
The E
suffix (short for Effect) means that the handlers return an effect (IO
).
Signature
export declare const matchE: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>
Added in v2.12.0
matchEW
Less strict version of matchE
.
The W
suffix (short for Widening) means that the handler return types will be merged.
Signature
export declare const matchEW: <B, C, A>(
onNone: () => I.IO<B>,
onSome: (a: A) => I.IO<C>
) => (ma: IOOption<A>) => I.IO<B | C>
Added in v2.12.0
matchW
Less strict version of match
.
The W
suffix (short for Widening) means that the handler return types will be merged.
Signature
export declare const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: IOOption<A>) => I.IO<B | C>
Added in v2.12.0
sequencing
chain
Signature
export declare const chain: <A, B>(f: (a: A) => IOOption<B>) => (ma: IOOption<A>) => IOOption<B>
Added in v2.12.0
chainEitherK
Signature
export declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<B>
Added in v2.12.0
chainFirst
Composes computations in sequence, using the return value of one computation to determine the next computation and keeping only the result of the first.
Signature
export declare const chainFirst: <A, B>(f: (a: A) => IOOption<B>) => (first: IOOption<A>) => IOOption<A>
Added in v2.12.0
chainFirstEitherK
Signature
export declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<A>
Added in v2.12.0
chainFirstIOK
Signature
export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<A>
Added in v2.12.0
chainIOK
Signature
export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<B>
Added in v2.12.0
chainNullableK
Signature
export declare const chainNullableK: <A, B>(
f: (a: A) => B | null | undefined
) => (ma: IOOption<A>) => IOOption<NonNullable<B>>
Added in v2.12.0
chainOptionK
Signature
export declare const chainOptionK: <A, B>(f: (a: A) => O.Option<B>) => (ma: IOOption<A>) => IOOption<B>
Added in v2.12.0
flatten
Signature
export declare const flatten: <A>(mma: IOOption<IOOption<A>>) => IOOption<A>
Added in v2.12.0
traversing
traverseReadonlyArrayWithIndex
Equivalent to ReadonlyArray#traverseWithIndex(Applicative)
.
Signature
export declare const traverseReadonlyArrayWithIndex: <A, B>(
f: (index: number, a: A) => IOOption<B>
) => (as: readonly A[]) => IOOption<readonly B[]>
Added in v2.12.0
traverseReadonlyNonEmptyArrayWithIndex
Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative)
.
Signature
export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(
f: (index: number, a: A) => IOOption<B>
) => (as: ReadonlyNonEmptyArray<A>) => IOOption<ReadonlyNonEmptyArray<B>>
Added in v2.12.0
type lambdas
URI
Signature
export declare const URI: 'IOOption'
Added in v2.12.0
URI (type alias)
Signature
export type URI = typeof URI
Added in v2.12.0
utils
ApT
Signature
export declare const ApT: IOOption<readonly []>
Added in v2.12.0
ap
Signature
export declare const ap: <A>(fa: IOOption<A>) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>
Added in v2.12.0
apFirst
Combine two effectful actions, keeping only the result of the first.
Signature
export declare const apFirst: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<A>
Added in v2.12.0
apSecond
Combine two effectful actions, keeping only the result of the second.
Signature
export declare const apSecond: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<B>
Added in v2.12.0
zero
Signature
export declare const zero: <A>() => IOOption<A>
Added in v2.12.0