Middleware overview

A middleware is an indexed monadic action transforming one Connection to another Connection. It operates in the TaskEither monad, and is indexed by I and O, the input and output Connection types of the middleware action.

Added in v0.7.0


Table of contents


Alt

alt

Signature

export declare const alt: <I, E, A>(
  that: Lazy<Middleware<I, I, E, A>>
) => (fa: Middleware<I, I, E, A>) => Middleware<I, I, E, A>

Added in v0.7.0

altW

Less strict version of alt.

Signature

export declare const altW: <I, E2, A>(
  that: Lazy<Middleware<I, I, E2, A>>
) => <E1>(fa: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, A>

Added in v0.7.5

Apply

ap

Apply a function to an argument under a type constructor.

Signature

export declare const ap: <I, E, A>(
  fa: Middleware<I, I, E, A>
) => <B>(fab: Middleware<I, I, E, (a: A) => B>) => Middleware<I, I, E, B>

Added in v0.7.0

apW

Less strict version of ap.

Signature

export declare const apW: <I, E2, A>(
  fa: Middleware<I, I, E2, A>
) => <E1, B>(fab: Middleware<I, I, E1, (a: A) => B>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.0

iap

Indexed version of ap.

Signature

export declare const iap: <O, Z, E, A>(
  fa: Middleware<O, Z, E, A>
) => <I, B>(fab: Middleware<I, O, E, (a: A) => B>) => Middleware<I, Z, E, B>

Added in v0.7.9

iapW

Less strict version of iap.

Signature

export declare const iapW: <O, Z, E2, A>(
  fa: Middleware<O, Z, E2, A>
) => <I, E1, B>(fab: Middleware<I, O, E1, (a: A) => B>) => Middleware<I, Z, E2 | E1, B>

Added in v0.7.9

Bifunctor

bimap

Map a pair of functions over the two last type arguments of the bifunctor.

Signature

export declare const bimap: <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => <I>(fa: Middleware<I, I, E, A>) => Middleware<I, I, G, B>

Added in v0.7.0

mapLeft

Map a function over the second type argument of a bifunctor.

Signature

export declare const mapLeft: <E, G>(f: (e: E) => G) => <I, A>(fa: Middleware<I, I, E, A>) => Middleware<I, I, G, A>

Added in v0.7.0

Functor

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) => <I, E>(fa: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.0

IxFunctor

imap

Indexed version of map.

Signature

export declare const imap: <A, B>(f: (a: A) => B) => <I, O, E>(fa: Middleware<I, O, E, A>) => Middleware<I, O, E, B>

Added in v0.7.0

IxMonad

ichain

Indexed version of chain.

Signature

export declare const ichain: <A, O, Z, E, B>(
  f: (a: A) => Middleware<O, Z, E, B>
) => <I>(ma: Middleware<I, O, E, A>) => Middleware<I, Z, E, B>

Added in v0.7.0

ichainW

Less strict version of ichain.

Signature

export declare function ichainW<A, O, Z, E, B>(
  f: (a: A) => Middleware<O, Z, E, B>
): <I, D>(ma: Middleware<I, O, D, A>) => Middleware<I, Z, D | E, B>

Added in v0.7.0

IxPointed

iof

Signature

export declare function iof<I = StatusOpen, O = StatusOpen, E = never, A = never>(a: A): Middleware<I, O, E, A>

Added in v0.7.0

Monad

chain

Composes computations in sequence, using the return value of one computation to determine the next computation.

Signature

export declare const chain: <I, E, A, B>(
  f: (a: A) => Middleware<I, I, E, B>
) => (ma: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.0

chainW

Less strict version of chain.

Signature

export declare const chainW: <I, E2, A, B>(
  f: (a: A) => Middleware<I, I, E2, B>
) => <E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.0

Pointed

of

Signature

export declare const of: <I = StatusOpen, E = never, A = never>(a: A) => Middleware<I, I, E, A>

Added in v0.7.0

combinators

apFirst

Signature

export declare const apFirst: <R, E, B>(
  second: Middleware<R, R, E, B>
) => <A>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, A>

Added in v0.7.0

apFirstW

Less strict version of apFirst.

Signature

export declare const apFirstW: <I, E2, B>(
  second: Middleware<I, I, E2, B>
) => <E1, A>(first: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, A>

Added in v0.7.1

apSecond

Signature

export declare const apSecond: <R, E, B>(
  second: Middleware<R, R, E, B>
) => <A>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, B>

Added in v0.7.0

apSecondW

Less strict version of apSecond.

Signature

export declare const apSecondW: <I, E2, B>(
  second: Middleware<I, I, E2, B>
) => <E1, A>(first: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.1

chainEitherK

Signature

export declare const chainEitherK: <E, A, B>(
  f: (a: A) => E.Either<E, B>
) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.0

chainEitherKW

Less strict version of chainEitherK.

Signature

export declare const chainEitherKW: <E2, A, B>(
  f: (a: A) => E.Either<E2, B>
) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.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.

Derivable from Chain.

Signature

export declare const chainFirst: <A, R, E, _>(
  f: (a: A) => Middleware<R, R, E, _>
) => (first: Middleware<R, R, E, A>) => Middleware<R, R, E, A>

Added in v0.7.0

chainFirstIOK

Signature

export declare const chainFirstIOK: <A, B>(
  f: (a: A) => IO<B>
) => <R, E>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, A>

Added in v0.7.0

chainFirstTaskEitherK

Signature

export declare const chainFirstTaskEitherK: <E, A, B>(
  f: (a: A) => TE.TaskEither<E, B>
) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, A>

Added in v0.7.0

chainFirstTaskEitherKW

Less strict version of chainFirstTaskEitherK.

Signature

export declare const chainFirstTaskEitherKW: <E2, A, B>(
  f: (a: A) => TE.TaskEither<E2, B>
) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, A>

Added in v0.7.0

chainFirstTaskK

Signature

export declare const chainFirstTaskK: <A, B>(
  f: (a: A) => T.Task<B>
) => <R, E>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, A>

Added in v0.7.0

chainFirstTaskOptionK

Signature

export declare const chainFirstTaskOptionK: <E>(
  onNone: Lazy<E>
) => <A, B>(f: (a: A) => TO.TaskOption<B>) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, A>

Added in v0.7.9

chainFirstTaskOptionKW

Less strict version of chainFirstTaskOptionK.

Signature

export declare const chainFirstTaskOptionKW: <E2>(
  onNone: Lazy<E2>
) => <A, B>(f: (a: A) => TO.TaskOption<B>) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, A>

Added in v0.7.9

chainFirstW

Less strict version of chainFirst.

Derivable from Chain.

Signature

export declare const chainFirstW: <I, E2, A, B>(
  f: (a: A) => Middleware<I, I, E2, B>
) => <E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, A>

Added in v0.7.0

chainIOK

Signature

export declare const chainIOK: <A, B>(
  f: (a: A) => IO<B>
) => <R, E>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, B>

Added in v0.7.0

chainOptionK

Signature

export declare const chainOptionK: <E>(
  onNone: Lazy<E>
) => <A, B>(f: (a: A) => O.Option<B>) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.9

chainOptionKW

Less strict version of chainOptionK.

Signature

export declare const chainOptionKW: <E2>(
  onNone: Lazy<E2>
) => <A, B>(f: (a: A) => O.Option<B>) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.9

chainTaskEitherK

Signature

export declare const chainTaskEitherK: <E, A, B>(
  f: (a: A) => TE.TaskEither<E, B>
) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.0

chainTaskEitherKW

Less strict version of chainTaskEitherK.

Signature

export declare const chainTaskEitherKW: <E2, A, B>(
  f: (a: A) => TE.TaskEither<E2, B>
) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.0

chainTaskK

Signature

export declare const chainTaskK: <A, B>(
  f: (a: A) => T.Task<B>
) => <R, E>(first: Middleware<R, R, E, A>) => Middleware<R, R, E, B>

Added in v0.7.0

chainTaskOptionK

Signature

export declare const chainTaskOptionK: <E>(
  onNone: Lazy<E>
) => <A, B>(f: (a: A) => TO.TaskOption<B>) => <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, B>

Added in v0.7.9

chainTaskOptionKW

Less strict version of chainTaskOptionK.

Signature

export declare const chainTaskOptionKW: <E2>(
  onNone: Lazy<E2>
) => <A, B>(f: (a: A) => TO.TaskOption<B>) => <I, E1>(ma: Middleware<I, I, E1, A>) => Middleware<I, I, E2 | E1, B>

Added in v0.7.9

filterOrElse

Signature

export declare const filterOrElse: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <I>(
    ma: Middleware<I, I, E, A>
  ) => Middleware<I, I, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <I>(ma: Middleware<I, I, E, A>) => Middleware<I, I, E, A>
}

Added in v0.7.0

filterOrElseW

Less strict version of filterOrElse.

Signature

export declare const filterOrElseW: {
  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <I, E1>(
    ma: Middleware<I, I, E1, A>
  ) => Middleware<I, I, E2 | E1, B>
  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <I, E1>(
    ma: Middleware<I, I, E1, A>
  ) => Middleware<I, I, E2 | E1, A>
}

Added in v0.7.0

flatten

Derivable from Chain.

Signature

export declare const flatten: <I, E, A>(mma: Middleware<I, I, E, Middleware<I, I, E, A>>) => Middleware<I, I, E, A>

Added in v0.7.0

flattenW

Less strict version of flatten.

Signature

export declare const flattenW: <I, E1, E2, A>(
  mma: Middleware<I, I, E1, Middleware<I, I, E2, A>>
) => Middleware<I, I, E1 | E2, A>

Added in v0.7.2

fromEitherK

Signature

export declare const fromEitherK: <E, A extends readonly unknown[], B>(
  f: (...a: A) => E.Either<E, B>
) => <I>(...a: A) => Middleware<I, I, E, B>

Added in v0.7.9

fromIOK

Signature

export declare const fromIOK: <A, B>(f: (...a: A) => IO<B>) => <R, E>(...a: A) => Middleware<R, R, E, B>

Added in v0.7.0

fromOptionK

Signature

export declare const fromOptionK: <E>(
  onNone: Lazy<E>
) => <A extends readonly unknown[], B>(f: (...a: A) => O.Option<B>) => <I>(...a: A) => Middleware<I, I, E, B>

Added in v0.7.9

fromTaskK

Signature

export declare const fromTaskK: <A, B>(f: (...a: A) => T.Task<B>) => <R, E>(...a: A) => Middleware<R, R, E, B>

Added in v0.7.0

iapFirst

Indexed version of apFirst.

Signature

export declare const iapFirst: <O, Z, E, B>(
  second: Middleware<O, Z, E, B>
) => <I, A>(first: Middleware<I, O, E, A>) => Middleware<I, Z, E, A>

Added in v0.7.9

iapFirstW

Less strict version of iapFirst.

Signature

export declare const iapFirstW: <O, Z, E2, B>(
  second: Middleware<O, Z, E2, B>
) => <I, E1, A>(first: Middleware<I, O, E1, A>) => Middleware<I, Z, E2 | E1, A>

Added in v0.7.1

iapSecond

Indexed version of apSecond.

Signature

export declare const iapSecond: <O, Z, E, B>(
  second: Middleware<O, Z, E, B>
) => <I, A>(first: Middleware<I, O, E, A>) => Middleware<I, Z, E, B>

Added in v0.7.9

iapSecondW

Less strict version of iapSecond.

Signature

export declare const iapSecondW: <O, Z, E2, B>(
  second: Middleware<O, Z, E2, B>
) => <I, E1, A>(first: Middleware<I, O, E1, A>) => Middleware<I, Z, E2 | E1, B>

Added in v0.7.9

ichainFirst

Indexed version of chainFirst.

Signature

export declare const ichainFirst: <A, O, Z, E, B>(
  f: (a: A) => Middleware<O, Z, E, B>
) => <I>(ma: Middleware<I, O, E, A>) => Middleware<I, Z, E, A>

Added in v0.7.6

ichainFirstW

Less strict version of ichainFirst.

Signature

export declare function ichainFirstW<A, O, Z, E, B>(
  f: (a: A) => Middleware<O, Z, E, B>
): <I, D>(ma: Middleware<I, O, D, A>) => Middleware<I, Z, D | E, A>

Added in v0.7.6

iflatten

Derivable from indexed version of Chain.

Signature

export declare const iflatten: <I, O, Z, E, A>(
  mma: Middleware<I, O, E, Middleware<O, Z, E, A>>
) => Middleware<I, Z, E, A>

Added in v0.7.2

iflattenW

Less strict version of iflatten.

Signature

export declare const iflattenW: <I, O, Z, E1, E2, A>(
  mma: Middleware<I, O, E1, Middleware<O, Z, E2, A>>
) => Middleware<I, Z, E1 | E2, A>

Added in v0.7.2

orElse

Signature

export declare const orElse: <E, I, O, M, A>(
  f: (e: E) => Middleware<I, O, M, A>
) => (ma: Middleware<I, O, E, A>) => Middleware<I, O, M, A>

Added in v0.7.0

orElseW

Less strict version of orElse.

Signature

export declare const orElseW: <E, I, O, M, B>(
  f: (e: E) => Middleware<I, O, M, B>
) => <A>(ma: Middleware<I, O, E, A>) => Middleware<I, O, M, B | A>

Added in v0.7.5

constructors

clearCookie

Returns a middleware that clears the cookie name

Signature

export declare function clearCookie<E = never>(
  name: string,
  options: CookieOptions
): Middleware<HeadersOpen, HeadersOpen, E, void>

Added in v0.7.0

closeHeaders

Returns a middleware that changes the connection status to BodyOpen

Signature

export declare function closeHeaders<E = never>(): Middleware<HeadersOpen, BodyOpen, E, void>

Added in v0.7.0

contentType

Returns a middleware that sets the given mediaType

Signature

export declare function contentType<E = never>(mediaType: MediaType): Middleware<HeadersOpen, HeadersOpen, E, void>

Added in v0.7.0

Returns a middleware that sets the cookie name to value, with the given options

Signature

export declare function cookie<E = never>(
  name: string,
  value: string,
  options: CookieOptions
): Middleware<HeadersOpen, HeadersOpen, E, void>

Added in v0.7.0

decodeBody

Returns a middleware that tries to decode connection.getBody()

Signature

export declare function decodeBody<I = StatusOpen, E = never, A = never>(
  f: (input: unknown) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

decodeHeader

Returns a middleware that tries to decode connection.getHeader(name)

Signature

export declare function decodeHeader<I = StatusOpen, E = never, A = never>(
  name: string,
  f: (input: unknown) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

decodeMethod

Returns a middleware that tries to decode connection.getMethod()

Signature

export declare function decodeMethod<I = StatusOpen, E = never, A = never>(
  f: (method: string) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

decodeParam

Returns a middleware that tries to decode connection.getParams()[name]

Signature

export declare function decodeParam<I = StatusOpen, E = never, A = never>(
  name: string,
  f: (input: unknown) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

decodeParams

Returns a middleware that tries to decode connection.getParams()

Signature

export declare function decodeParams<I = StatusOpen, E = never, A = never>(
  f: (input: unknown) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

decodeQuery

Returns a middleware that tries to decode connection.getQuery()

Signature

export declare function decodeQuery<I = StatusOpen, E = never, A = never>(
  f: (input: unknown) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

end

Returns a middleware that ends the response without sending any response body

Signature

export declare function end<E = never>(): Middleware<BodyOpen, ResponseEnded, E, void>

Added in v0.7.0

fromConnection

Signature

export declare function fromConnection<I = StatusOpen, E = never, A = never>(
  f: (c: Connection<I>) => E.Either<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

fromPredicate

Signature

export declare const fromPredicate: {
  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <I>(a: A) => Middleware<I, I, E, B>
  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <I>(a: A) => Middleware<I, I, E, A>
}

Added in v0.7.0

gets

Signature

export declare function gets<I = StatusOpen, E = never, A = never>(f: (c: Connection<I>) => A): Middleware<I, I, E, A>

Added in v0.7.0

Returns a middleware that writes the given header

Signature

export declare function header<E = never>(name: string, value: string): Middleware<HeadersOpen, HeadersOpen, E, void>

Added in v0.7.0

json

Returns a middleware that sends body as JSON

Signature

export declare function json<E>(
  body: unknown,
  onError: (reason: unknown) => E
): Middleware<HeadersOpen, ResponseEnded, E, void>

Added in v0.7.0

left

Signature

export declare function left<I = StatusOpen, E = never, A = never>(e: E): Middleware<I, I, E, A>

Added in v0.7.0

leftIO

Signature

export declare function leftIO<I = StatusOpen, E = never, A = never>(fe: IO<E>): Middleware<I, I, E, A>

Added in v0.7.0

leftTask

Signature

export declare function leftTask<I = StatusOpen, E = never, A = never>(te: T.Task<E>): Middleware<I, I, E, A>

Added in v0.7.0

modifyConnection

Signature

export declare function modifyConnection<I, O, E>(f: (c: Connection<I>) => Connection<O>): Middleware<I, O, E, void>

Added in v0.7.0

pipeStream

Returns a middleware that pipes a stream to the response object.

Signature

export declare function pipeStream<E>(
  stream: NodeJS.ReadableStream,
  onError: (err: unknown) => IO<void>
): Middleware<BodyOpen, ResponseEnded, E, void>

Added in v0.7.0

redirect

Returns a middleware that sends a redirect to uri

Signature

export declare function redirect<E = never>(
  uri: string | { href: string }
): Middleware<StatusOpen, HeadersOpen, E, void>

Added in v0.7.0

Signature

export declare function right<I = StatusOpen, E = never, A = never>(a: A): Middleware<I, I, E, A>

Added in v0.7.0

rightIO

Signature

export declare function rightIO<I = StatusOpen, E = never, A = never>(fa: IO<A>): Middleware<I, I, E, A>

Added in v0.7.0

rightTask

Signature

export declare function rightTask<I = StatusOpen, E = never, A = never>(fa: T.Task<A>): Middleware<I, I, E, A>

Added in v0.7.0

send

Returns a middleware that sends body as response body

Signature

export declare function send<E = never>(body: string | Buffer): Middleware<BodyOpen, ResponseEnded, E, void>

Added in v0.7.0

status

Returns a middleware that writes the response status

Signature

export declare function status<E = never>(status: Status): Middleware<StatusOpen, HeadersOpen, E, void>

Added in v0.7.0

instances

Alt

Signature

export declare const Alt: Alt3<'Middleware'>

Added in v0.7.0

ApplicativePar

Signature

export declare const ApplicativePar: Applicative3<'Middleware'>

Added in v0.7.0

ApplicativeSeq

Signature

export declare const ApplicativeSeq: Applicative3<'Middleware'>

Added in v0.7.0

ApplyPar

Signature

export declare const ApplyPar: Apply3<'Middleware'>

Added in v0.7.0

ApplySeq

Signature

export declare const ApplySeq: Apply3<'Middleware'>

Added in v0.7.0

Bifunctor

Signature

export declare const Bifunctor: Bifunctor3<'Middleware'>

Added in v0.7.0

Chain

Signature

export declare const Chain: Chain3<'Middleware'>

Added in v0.7.0

FromEither

Signature

export declare const FromEither: FromEither3<'Middleware'>

Added in v0.7.0

FromIO

Signature

export declare const FromIO: FromIO3<'Middleware'>

Added in v0.7.0

FromTask

Signature

export declare const FromTask: FromTask3<'Middleware'>

Added in v0.7.0

Functor

Signature

export declare const Functor: Functor3<'Middleware'>

Added in v0.7.0

Monad

Signature

export declare const Monad: Monad3<'Middleware'>

Added in v0.7.0

MonadTask

Signature

export declare const MonadTask: MonadTask3<'Middleware'>

Added in v0.7.0

MonadThrow

Signature

export declare const MonadThrow: MonadThrow3<'Middleware'>

Added in v0.7.0

Pointed

Signature

export declare const Pointed: Pointed3<'Middleware'>

Added in v0.7.0

URI

Signature

export declare const URI: 'Middleware'

Added in v0.7.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v0.7.0

interop

tryCatch

Signature

export declare function tryCatch<I = StatusOpen, E = never, A = never>(
  f: () => Promise<A>,
  onRejected: (reason: unknown) => E
): Middleware<I, I, E, A>

Added in v0.7.0

model

Middleware (interface)

A middleware is an indexed monadic action transforming one Connection to another Connection. It operates in the TaskEither monad, and is indexed by I and O, the input and output Connection types of the middleware action.

Signature

export interface Middleware<I, O, E, A> {
  (c: Connection<I>): TE.TaskEither<E, [A, Connection<O>]>
}

Added in v0.7.0

natural transformations

fromEither

Signature

export declare const fromEither: <I = StatusOpen, E = never, A = never>(fa: E.Either<E, A>) => Middleware<I, I, E, A>

Added in v0.7.0

fromIO

Signature

export declare const fromIO: <A, R, E>(fa: IO<A>) => Middleware<R, R, E, A>

Added in v0.7.0

fromIOEither

Signature

export declare function fromIOEither<I = StatusOpen, E = never, A = never>(fa: IOEither<E, A>): Middleware<I, I, E, A>

Added in v0.7.0

fromOption

Signature

export declare const fromOption: <E>(onNone: Lazy<E>) => <I, A>(ma: O.Option<A>) => Middleware<I, I, E, A>

Added in v0.7.0

fromTask

Signature

export declare const fromTask: <A, R, E>(fa: T.Task<A>) => Middleware<R, R, E, A>

Added in v0.7.0

fromTaskEither

Signature

export declare function fromTaskEither<I = StatusOpen, E = never, A = never>(
  fa: TE.TaskEither<E, A>
): Middleware<I, I, E, A>

Added in v0.7.0

fromTaskOption

Signature

export declare const fromTaskOption: <E>(
  onNone: Lazy<E>
) => <I = StatusOpen, A = never>(fa: TO.TaskOption<A>) => Middleware<I, I, E, A>

Added in v0.7.9

utils

apS

Signature

export declare const apS: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  fb: Middleware<R, R, E, B>
) => (fa: Middleware<R, R, E, A>) => Middleware<R, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

apSW

Less strict version of apS.

Signature

export declare const apSW: <N extends string, A, I, E2, B>(
  name: Exclude<N, keyof A>,
  fb: Middleware<I, I, E2, B>
) => <E1>(
  fa: Middleware<I, I, E1, A>
) => Middleware<I, I, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

bind

Signature

export declare const bind: <N, A, R, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Middleware<R, R, E, B>
) => (ma: Middleware<R, R, E, A>) => Middleware<R, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

bindTo

Signature

export declare const bindTo: <N>(
  name: N
) => <R, E, A>(fa: Middleware<R, R, E, A>) => Middleware<R, R, E, { readonly [K in N]: A }>

Added in v0.7.0

bindW

Signature

export declare const bindW: <N extends string, I, A, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Middleware<I, I, E2, B>
) => <E1>(
  fa: Middleware<I, I, E1, A>
) => Middleware<I, I, E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

evalMiddleware

Signature

export declare function evalMiddleware<I, O, E, A>(ma: Middleware<I, O, E, A>, c: Connection<I>): TE.TaskEither<E, A>

Added in v0.7.0

execMiddleware

Signature

export declare function execMiddleware<I, O, E, A>(
  ma: Middleware<I, O, E, A>,
  c: Connection<I>
): TE.TaskEither<E, Connection<O>>

Added in v0.7.0

iapS

Signature

export declare const iapS: <N extends string, A, I, O, E, B>(
  name: Exclude<N, keyof A>,
  fb: Middleware<I, O, E, B>
) => (fa: Middleware<I, O, E, A>) => Middleware<I, O, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

iapSW

Less strict version of iapS.

Signature

export declare const iapSW: <N extends string, A, I, O, E2, B>(
  name: Exclude<N, keyof A>,
  fb: Middleware<I, O, E2, B>
) => <E1>(
  fa: Middleware<I, O, E1, A>
) => Middleware<I, O, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

ibind

Signature

export declare const ibind: <N extends string, A, O, Z, E, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Middleware<O, Z, E, B>
) => <I>(
  ma: Middleware<I, O, E, A>
) => Middleware<I, Z, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

ibindTo

Indexed version of bindTo.

Signature

export declare const ibindTo: <N extends string>(
  name: N
) => <I, O, E, A>(fa: Middleware<I, O, E, A>) => Middleware<I, O, E, { readonly [K in N]: A }>

Added in v0.7.0

ibindW

Less strict version of ibind.

Signature

export declare const ibindW: <N extends string, A, O, Z, E2, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Middleware<O, Z, E2, B>
) => <I, E1>(
  ma: Middleware<I, O, E1, A>
) => Middleware<I, Z, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v0.7.0

Do

Phantom type can’t be infered properly, use bindTo instead.

Signature

export declare const Do: Middleware<unknown, unknown, never, {}>

Added in v0.7.0