IoEither
Instances
- Alt
- ApplicativePar
- ApplicativeSeq
- ApplyPar
- Bifunctor
- Chain
- ChainRec
- FromEither
- FromIO
- Functor
- Monad
- MonadIO
- MonadThrow
- Pointed
Combinators
Constructors
Conversions
Do notation
Error handling
- alt
- altW
- getAltIOValidation
- getApplicativeIOValidation
- getOrElse
- getOrElseW
- mapBoth
- mapError
- orElse
- orElseFirstIOK
- orElseW
- orLeft
- tapError
Filtering
Instance Methods
Interop
Legacy
- bimap
- chain
- chainEitherK
- chainEitherKW
- chainFirst
- chainFirstEitherK
- chainFirstEitherKW
- chainFirstIOK
- chainFirstW
- chainIOK
- chainOptionK
- chainOptionKW
- chainW
- fromOptionK
- mapLeft
- orElseFirst
- orElseFirstW
Lifting
Mapping
Model
Pattern matching
Sequencing
Traversing
- sequenceArray
- sequenceSeqArray
- traverseArray
- traverseArrayWithIndex
- traverseReadonlyArrayWithIndex
- traverseReadonlyArrayWithIndexSeq
- traverseReadonlyNonEmptyArrayWithIndex
- traverseReadonlyNonEmptyArrayWithIndexSeq
- traverseSeqArray
- traverseSeqArrayWithIndex
Type lambdas
Utilities
- ApT
Applicative(deprecated)- ap
- apFirst
- apFirstW
- apSecond
- apSecondW
- apW
- bracket
- bracketW
- do
getApplyMonoid(deprecated)getApplySemigroup(deprecated)getIOValidation(deprecated)getSemigroup(deprecated)ioEither(deprecated)- let
- swap
- throwError
Instances
Alt
Signature
export declare const Alt: Alt2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
ApplicativePar
Runs computations in parallel.
Signature
export declare const ApplicativePar: Applicative2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
ApplicativeSeq
Runs computations sequentially.
Signature
export declare const ApplicativeSeq: Applicative2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
ApplyPar
Runs computations in parallel.
Signature
export declare const ApplyPar: Apply2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Bifunctor
Signature
export declare const Bifunctor: Bifunctor2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Chain
Signature
export declare const Chain: chainable.Chain2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
ChainRec
Signature
export declare const ChainRec: ChainRec2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2022-present Jacob Alford
FromEither
Signature
export declare const FromEither: FromEither2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
FromIO
Signature
export declare const FromIO: FromIO2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Functor
Signature
export declare const Functor: Functor2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Monad
Signature
export declare const Monad: Monad2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
MonadIO
Signature
export declare const MonadIO: MonadIO2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
MonadThrow
Signature
export declare const MonadThrow: MonadThrow2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Pointed
Signature
export declare const Pointed: Pointed2<URI>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Combinators
tap
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 tap: {
<E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => IOEither<E2, _>): IOEither<E1 | E2, A>
<A, E2, _>(f: (a: A) => IOEither<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
tapEither
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 tapEither: {
<A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>
<E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => Either<E2, _>): IOEither<E1 | E2, A>
}
Details
- Added in 0.1.0
Example
import { pipe } from '@fp-tx/core/function'
import * as IOE from '@fp-tx/core/IOEither'
import * as E from '@fp-tx/core/Either'
const compute = (value: string) =>
pipe(
IOE.of(value),
IOE.tapEither(() => (value.length > 0 ? E.right('ok') : E.left('error'))),
)
assert.deepStrictEqual(compute('')(), E.left('error'))
assert.deepStrictEqual(compute('fp-ts')(), E.right('fp-ts'))
License
- MIT – Copyright (c) 2017-present Giulio Canti
tapIO
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 tapIO: {
<A, _>(f: (a: A) => IO<_>): <E>(self: IOEither<E, A>) => IOEither<E, A>
<E, A, _>(self: IOEither<E, A>, f: (a: A) => IO<_>): IOEither<E, A>
}
Details
- Added in 0.1.0
Example
import { pipe } from '@fp-tx/core/function'
import * as IOE from '@fp-tx/core/IOEither'
import * as E from '@fp-tx/core/Either'
import * as Console from '@fp-tx/core/Console'
const sayHello = (value: string) => Console.log(`Hello, ${value}`)
// Will produce `Hello, fp-ts` to the stdout
const effectA = IOE.tapIO(IOE.of('fp-ts'), sayHello)
// No output to the stdout
const effectB = pipe(IOE.left<string>('error'), IOE.tapIO(sayHello))
assert.deepStrictEqual(effectA(), E.right('fp-ts'))
assert.deepStrictEqual(effectB(), E.left('error'))
License
- MIT – Copyright (c) 2017-present Giulio Canti
Constructors
left
Signature
export declare const left: <E = never, A = never>(l: E) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
leftIO
Signature
export declare const leftIO: <E = never, A = never>(me: IO<E>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
of
Signature
export declare const of: <E = never, A = never>(a: A) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
right
Signature
export declare const right: <E = never, A = never>(a: A) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
rightIO
Signature
export declare const rightIO: <E = never, A = never>(ma: IO<A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Conversions
fromEither
Signature
export declare const fromEither: <E, A>(fa: Either<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
fromIO
Signature
export declare const fromIO: <A, E = never>(fa: IO<A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
fromOption
Signature
export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
toUnion
Signature
export declare const toUnion: <E, A>(fa: IOEither<E, A>) => IO<E | A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Do notation
Do
Signature
export declare const Do: IOEither<never, {}>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apS
Signature
export declare const apS: <N extends string, A, E, B>(
name: Exclude<N, keyof A>,
fb: IOEither<E, B>,
) => (fa: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apSW
Less strict version of apS
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const apSW: <A, N extends string, E2, B>(
name: Exclude<N, keyof A>,
fb: IOEither<E2, B>,
) => <E1>(fa: IOEither<E1, A>) => IOEither<
E1 | E2,
{
readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
}
>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
bind
Signature
export declare const bind: <N extends string, A, E, B>(
name: Exclude<N, keyof A>,
f: (a: A) => IOEither<E, B>,
) => (ma: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
bindTo
Signature
export declare const bindTo: <N extends string>(
name: N,
) => <E, A>(fa: IOEither<E, A>) => IOEither<E, { readonly [K in N]: A }>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
bindW
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const bindW: <N extends string, A, E2, B>(
name: Exclude<N, keyof A>,
f: (a: A) => IOEither<E2, B>,
) => <E1>(fa: IOEither<E1, A>) => IOEither<
E1 | E2,
{
readonly [K in keyof A | N]: K extends keyof A ? A[K] : B
}
>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Error handling
alt
Identifies an associative operation on a type constructor. It is similar to Semigroup
, except that it applies to types of kind * -> *
.
Signature
export declare const alt: <E, A>(that: LazyArg<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
altW
Less strict version of alt
.
The W
suffix (short for Widening) means that the error and the return types will be merged.
Signature
export declare const altW: <E2, B>(
that: LazyArg<IOEither<E2, B>>,
) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2, A | B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
getAltIOValidation
The default Alt
instance returns the last error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup
.
See getAltValidation
.
Signature
export declare function getAltIOValidation<E>(S: Semigroup<E>): Alt2C<URI, E>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
getApplicativeIOValidation
The default ApplicativePar
instance returns the first error, if you want to get all errors you need to provide a way to concatenate them via a Semigroup
.
Signature
export declare function getApplicativeIOValidation<E>(S: Semigroup<E>): Applicative2C<URI, E>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
getOrElse
Signature
export declare const getOrElse: <E, A>(onLeft: (e: E) => IO<A>) => (ma: IOEither<E, A>) => IO<A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
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: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IO<A | B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
mapBoth
Returns a IOEither
whose failure and success channels have been mapped by the specified pair of functions, f
and g
.
Signature
export declare const mapBoth: {
<E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: IOEither<E, A>) => IOEither<G, B>
<E, A, G, B>(self: IOEither<E, A>, f: (e: E) => G, g: (a: A) => B): IOEither<G, B>
}
Details
- Added in 0.1.0
Example
import * as IOEither from '@fp-tx/core/IOEither'
import * as Either from '@fp-tx/core/Either'
const f = (s: string) => new Error(s)
const g = (n: number) => n * 2
assert.deepStrictEqual(IOEither.mapBoth(IOEither.right(1), f, g)(), Either.right(2))
assert.deepStrictEqual(IOEither.mapBoth(IOEither.left('err'), f, g)(), Either.left(new Error('err')))
License
- MIT – Copyright (c) 2017-present Giulio Canti
mapError
Returns a IOEither
with its error channel mapped using the specified function.
Signature
export declare const mapError: {
<E, G>(f: (e: E) => G): <A>(self: IOEither<E, A>) => IOEither<G, A>
<E, A, G>(self: IOEither<E, A>, f: (e: E) => G): IOEither<G, A>
}
Details
- Added in 0.1.0
Example
import * as IOEither from '@fp-tx/core/IOEither'
import * as Either from '@fp-tx/core/Either'
const f = (s: string) => new Error(s)
assert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1))
assert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err')))
License
- MIT – Copyright (c) 2017-present Giulio Canti
orElse
Signature
export declare const orElse: <E1, A, E2>(onLeft: (e: E1) => IOEither<E2, A>) => (ma: IOEither<E1, A>) => IOEither<E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
orElseFirstIOK
Signature
export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
orElseW
Less strict version of orElse
.
The W
suffix (short for Widening) means that the return types will be merged.
Signature
export declare const orElseW: <E1, E2, B>(
onLeft: (e: E1) => IOEither<E2, B>,
) => <A>(ma: IOEither<E1, A>) => IOEither<E2, A | B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
orLeft
Signature
export declare const orLeft: <E1, E2>(onLeft: (e: E1) => IO<E2>) => <A>(fa: IOEither<E1, A>) => IOEither<E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
tapError
Returns an effect that effectfully "peeks" at the failure of this effect.
Signature
export declare const tapError: {
<E1, E2, _>(onLeft: (e: E1) => IOEither<E2, _>): <A>(self: IOEither<E1, A>) => IOEither<E1 | E2, A>
<E1, A, E2, _>(self: IOEither<E1, A>, onLeft: (e: E1) => IOEither<E2, _>): IOEither<E1 | E2, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Filtering
filterOrElse
Signature
export declare const filterOrElse: {
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, B>
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: IOEither<E, B>) => IOEither<E, B>
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
filterOrElseW
Less strict version of filterOrElse
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const filterOrElseW: {
<A, B extends A, E2>(
refinement: Refinement<A, B>,
onFalse: (a: A) => E2,
): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>
<A, E2>(
predicate: Predicate<A>,
onFalse: (a: A) => E2,
): <E1, B extends A>(mb: IOEither<E1, B>) => IOEither<E1 | E2, B>
<A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
getCompactable
Signature
export declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'IOEither', E>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
getFilterable
Signature
export declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Instance Methods
chainRec
Signature
export declare const chainRec: ChainRec2<URI>['chainRec']
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2022-present Jacob Alford
Interop
tryCatch
Constructs a new IOEither
from a function that performs a side effect and might throw
See also tryCatchK
.
Signature
export declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (reason: unknown) => E) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
tryCatchK
Converts a function that may throw to one returning a IOEither
.
Signature
export declare const tryCatchK: <A extends readonly unknown[], B, E>(
f: (...a: A) => B,
onThrow: (reason: unknown) => E,
) => (...a: A) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Legacy
bimap
Alias of mapBoth
.
Signature
export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chain
Alias of flatMap
.
Signature
export declare const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainEitherK
Alias of flatMapEither
.
Signature
export declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainEitherKW
Alias of flatMapEither
.
Signature
export declare const chainEitherKW: <E2, A, B>(
f: (a: A) => Either<E2, B>,
) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainFirst
Alias of tap
.
Signature
export declare const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainFirstEitherK
Alias of tapEither
.
Signature
export declare const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainFirstEitherKW
Alias of tapEither
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const chainFirstEitherKW: <A, E2, B>(
f: (a: A) => E.Either<E2, B>,
) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainFirstIOK
Alias of tapIO
.
Signature
export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainFirstW
Alias of tap
.
Signature
export declare const chainFirstW: <E2, A, B>(
f: (a: A) => IOEither<E2, B>,
) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainIOK
Alias of flatMapIO
.
Signature
export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainOptionK
Use flatMapOption
.
Signature
export declare const chainOptionK: <E>(
onNone: LazyArg<E>,
) => <A, B>(f: (a: A) => Option<B>) => (ma: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainOptionKW
Use flatMapOption
.
Signature
export declare const chainOptionKW: <E2>(
onNone: LazyArg<E2>,
) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
chainW
Alias of flatMap
.
Signature
export declare const chainW: <E2, A, B>(
f: (a: A) => IOEither<E2, B>,
) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
fromOptionK
Use liftOption
.
Signature
export declare const fromOptionK: <E>(
onNone: LazyArg<E>,
) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
mapLeft
Alias of mapError
.
Signature
export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
orElseFirst
Alias of tapError
.
Signature
export declare const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
orElseFirstW
Alias of tapError
.
Signature
export declare const orElseFirstW: <E1, E2, B>(
onLeft: (e: E1) => IOEither<E2, B>,
) => <A>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Lifting
fromEitherK
Signature
export declare const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(
f: (...a: A) => E.Either<E, B>,
) => (...a: A) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
fromIOK
Signature
export declare const fromIOK: <A extends ReadonlyArray<unknown>, B>(
f: (...a: A) => I.IO<B>,
) => <E = never>(...a: A) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
fromPredicate
Signature
export declare const fromPredicate: {
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => IOEither<E, B>
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => IOEither<E, B>
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => IOEither<E, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
liftNullable
Signature
export declare const liftNullable: <A extends ReadonlyArray<unknown>, B, E>(
f: (...a: A) => B | null | undefined,
onNullable: (...a: A) => E,
) => (...a: A) => IOEither<E, NonNullable<B>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
liftOption
Signature
export declare const liftOption: <A extends ReadonlyArray<unknown>, B, E>(
f: (...a: A) => Option<B>,
onNone: (...a: A) => E,
) => (...a: A) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Mapping
as
Maps the Right
value of this IOEither
to the specified constant value.
Signature
export declare const as: {
<A>(a: A): <E, _>(self: IOEither<E, _>) => IOEither<E, A>
<E, _, A>(self: IOEither<E, _>, a: A): IOEither<E, A>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
asUnit
Maps the Right
value of this IOEither
to the void constant value.
Signature
export declare const asUnit: <E, _>(self: IOEither<E, _>) => IOEither<E, void>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flap
Signature
export declare const flap: <A>(a: A) => <E, B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
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) => <E>(fa: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Model
IOEither
Signature
export interface IOEither<E, A> extends IO<Either<E, A>> {}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Pattern matching
fold
Alias of matchE
.
Signature
export declare const fold: <E, A, B>(
onLeft: (e: E) => I.IO<B>,
onRight: (a: A) => I.IO<B>,
) => (ma: IOEither<E, A>) => I.IO<B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
foldW
Alias of matchEW
.
Signature
export declare const foldW: <E, B, A, C>(
onLeft: (e: E) => I.IO<B>,
onRight: (a: A) => I.IO<C>,
) => (ma: IOEither<E, A>) => I.IO<B | C>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
match
Signature
export declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither<E, A>) => IO<B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
matchE
The E
suffix (short for Effect) means that the handlers return an effect (IO
).
Signature
export declare const matchE: <E, A, B>(
onLeft: (e: E) => IO<B>,
onRight: (a: A) => IO<B>,
) => (ma: IOEither<E, A>) => IO<B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
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: <E, B, A, C>(
onLeft: (e: E) => IO<B>,
onRight: (a: A) => IO<C>,
) => (ma: IOEither<E, A>) => IO<B | C>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
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: <E, B, A, C>(
onLeft: (e: E) => B,
onRight: (a: A) => C,
) => (ma: IOEither<E, A>) => IO<B | C>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Sequencing
flatMap
Signature
export declare const flatMap: {
<A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>
<E1, A, E2, B>(ma: IOEither<E1, A>, f: (a: A) => IOEither<E2, B>): IOEither<E1 | E2, B>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flatMapEither
Signature
export declare const flatMapEither: {
<A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: IOEither<E1, A>) => IOEither<E1 | E2, B>
<E1, A, E2, B>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, B>): IOEither<E1 | E2, B>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flatMapIO
Signature
export declare const flatMapIO: {
<A, B>(f: (a: A) => IO<B>): <E>(self: IOEither<E, A>) => IOEither<E, B>
<E, A, B>(self: IOEither<E, A>, f: (a: A) => IO<B>): IOEither<E, B>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flatMapNullable
Signature
export declare const flatMapNullable: {
<A, B, E2>(
f: (a: A) => B | null | undefined,
onNullable: (a: A) => E2,
): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, NonNullable<B>>
<E1, A, B, E2>(
self: IOEither<E1, A>,
f: (a: A) => B | null | undefined,
onNullable: (a: A) => E2,
): IOEither<E1 | E2, NonNullable<B>>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flatMapOption
Signature
export declare const flatMapOption: {
<A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B>
<E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): IOEither<E1 | E2, B>
}
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flatten
Signature
export declare const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
flattenW
Less strict version of flatten
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const flattenW: <E1, E2, A>(mma: IOEither<E1, IOEither<E2, A>>) => IOEither<E1 | E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Traversing
sequenceArray
Equivalent to ReadonlyArray#sequence(Applicative)
.
Signature
export declare const sequenceArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
sequenceSeqArray
Equivalent to ReadonlyArray#sequence(ApplicativeSeq)
.
Signature
export declare const sequenceSeqArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseArray
Equivalent to ReadonlyArray#traverse(Applicative)
.
Signature
export declare const traverseArray: <A, E, B>(
f: (a: A) => IOEither<E, B>,
) => (as: readonly A[]) => IOEither<E, readonly B[]>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseArrayWithIndex
Equivalent to ReadonlyArray#traverseWithIndex(Applicative)
.
Signature
export declare const traverseArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseReadonlyArrayWithIndex
Equivalent to ReadonlyArray#traverseWithIndex(ApplicativePar)
.
Signature
export declare const traverseReadonlyArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: readonly A[]) => IOEither<E, readonly B[]>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseReadonlyArrayWithIndexSeq
Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq)
.
Signature
export declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: readonly A[]) => IOEither<E, readonly B[]>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseReadonlyNonEmptyArrayWithIndex
Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)
.
Signature
export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseReadonlyNonEmptyArrayWithIndexSeq
Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)
.
Signature
export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseSeqArray
Equivalent to ReadonlyArray#traverse(ApplicativeSeq)
.
Signature
export declare const traverseSeqArray: <A, E, B>(
f: (a: A) => IOEither<E, B>,
) => (as: readonly A[]) => IOEither<E, readonly B[]>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
traverseSeqArrayWithIndex
Equivalent to ReadonlyArray#traverseWithIndex(ApplicativeSeq)
.
Signature
export declare const traverseSeqArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>,
) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Type lambdas
URI
Signature
export type URI = typeof URI
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
URI
Signature
export declare const URI = 'IOEither'
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Utilities
ApT
Signature
export declare const ApT: IOEither<never, readonly []>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
Applicative
Applicative
Use ApplicativePar
instead
Signature
export declare const Applicative: Applicative2<URI>
Details
- Added in 0.1.0
- Deprecated
License
- MIT – Copyright (c) 2017-present Giulio Canti
ap
Signature
export declare const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apFirst
Combine two effectful actions, keeping only the result of the first.
Signature
export declare const apFirst: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apFirstW
Less strict version of apFirst
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const apFirstW: <E2, B>(
second: IOEither<E2, B>,
) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, A>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apSecond
Combine two effectful actions, keeping only the result of the second.
Signature
export declare const apSecond: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apSecondW
Less strict version of apSecond
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const apSecondW: <E2, B>(
second: IOEither<E2, B>,
) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
apW
Less strict version of ap
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const apW: <E2, A>(
fa: IOEither<E2, A>,
) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E1 | E2, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
bracket
Make sure that a resource is cleaned up in the event of an exception (). The release action is called regardless of whether the body action throws () or returns.
(*) i.e. returns a Left
Signature
export declare const bracket: <E, A, B>(
acquire: IOEither<E, A>,
use: (a: A) => IOEither<E, B>,
release: (a: A, e: E.Either<E, B>) => IOEither<E, void>,
) => IOEither<E, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
bracketW
Less strict version of bracket
.
The W
suffix (short for Widening) means that the error types will be merged.
Signature
export declare const bracketW: <E1, A, E2, B, E3>(
acquire: IOEither<E1, A>,
use: (a: A) => IOEither<E2, B>,
release: (a: A, e: E.Either<E2, B>) => IOEither<E3, void>,
) => IOEither<E1 | E2 | E3, B>
Details
- Added in 0.1.0
License
- MIT – Copyright (c) 2017-present Giulio Canti
do
Signature
export declare const do_: <MA extends IOEitherIterable<any, any>, A>(
yieldFunction: (unwrap: <E, A>(ma: IOEither<E, A>) => IOEitherIterable<E, A>) => Generator<MA, A>,
) => IOEither<MA extends IOEitherIterable<infer E, any> ? E : never, A>
getApplyMonoid
getApplyMonoid
Use getApplicativeMonoid
instead.
Signature
export declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<IOEither<E, A>>
Details
- Added in 0.1.0
- Deprecated
License
- MIT – Copyright (c) 2017-present Giulio Canti
getApplySemigroup
getApplySemigroup
Use getApplySemigroup
instead.
Signature
export declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>>