Reader overview

Added in v2.0.0


Table of contents


Applicative

of

Signature

export declare const of: <E, A>(a: A) => Reader<E, A>

Added in v2.0.0

Apply

ap

Apply a function to an argument under a type constructor.

Signature

export declare const ap: <R, A>(fa: Reader<R, A>) => <B>(fab: Reader<R, (a: A) => B>) => Reader<R, B>

Added in v2.0.0

apFirst

Combine two effectful actions, keeping only the result of the first.

Signature

export declare const apFirst: <R, B>(fb: Reader<R, B>) => <A>(fa: Reader<R, A>) => Reader<R, A>

Added in v2.0.0

apSecond

Combine two effectful actions, keeping only the result of the second.

Signature

export declare const apSecond: <R, B>(fb: Reader<R, B>) => <A>(fa: Reader<R, A>) => Reader<R, B>

Added in v2.0.0

apW

Less strict version of ap.

Signature

export declare const apW: <Q, A>(fa: Reader<Q, A>) => <R, B>(fab: Reader<R, (a: A) => B>) => Reader<Q & R, B>

Added in v2.8.0

Category

id

Signature

export declare const id: <A>() => Reader<A, A>

Added in v2.0.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) => <R>(fa: Reader<R, A>) => Reader<R, B>

Added in v2.0.0

Monad

chain

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

Signature

export declare const chain: <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Reader<R, A>) => Reader<R, B>

Added in v2.0.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, R, B>(f: (a: A) => Reader<R, B>) => (ma: Reader<R, A>) => Reader<R, A>

Added in v2.0.0

chainW

Less strict version of chain.

Signature

export declare const chainW: <R, A, B>(f: (a: A) => Reader<R, B>) => <Q>(ma: Reader<Q, A>) => Reader<Q & R, B>

Added in v2.6.0

flatten

Signature

export declare const flatten: <R, A>(mma: Reader<R, Reader<R, A>>) => Reader<R, A>

Added in v2.0.0

Profunctor

promap

Signature

export declare const promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Reader<E, A>) => Reader<D, B>

Added in v2.0.0

Semigroupoid

compose

Signature

export declare const compose: <A, B>(ab: Reader<A, B>) => <C>(bc: Reader<B, C>) => Reader<A, C>

Added in v2.0.0

combinators

local

Changes the value of the local context during the execution of the action ma (similar to Contravariant’s contramap).

Signature

export declare const local: <Q, R>(f: (d: Q) => R) => <A>(ma: Reader<R, A>) => Reader<Q, A>

Added in v2.0.0

constructors

ask

Reads the current context

Signature

export declare const ask: <R>() => Reader<R, R>

Added in v2.0.0

asks

Projects a value from the global context in a Reader

Signature

export declare const asks: <R, A>(f: (r: R) => A) => Reader<R, A>

Added in v2.0.0

instances

Applicative

Signature

export declare const Applicative: Applicative2<'Reader'>

Added in v2.7.0

Category

Signature

export declare const Category: Category2<'Reader'>

Added in v2.7.0

Choice

Signature

export declare const Choice: Choice2<'Reader'>

Added in v2.8.3

Functor

Signature

export declare const Functor: Functor2<'Reader'>

Added in v2.7.0

Monad

Signature

export declare const Monad: Monad2<'Reader'>

Added in v2.7.0

Profunctor

Signature

export declare const Profunctor: Profunctor2<'Reader'>

Added in v2.7.0

Strong

Signature

export declare const Strong: Strong2<'Reader'>

Added in v2.8.3

URI

Signature

export declare const URI: 'Reader'

Added in v2.0.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v2.0.0

getMonoid

Signature

export declare function getMonoid<R, A>(M: Monoid<A>): Monoid<Reader<R, A>>

Added in v2.0.0

getSemigroup

Signature

export declare function getSemigroup<R, A>(S: Semigroup<A>): Semigroup<Reader<R, A>>

Added in v2.0.0

reader

Signature

export declare const reader: Monad2<'Reader'> &
  Profunctor2<'Reader'> &
  Category2<'Reader'> &
  Strong2<'Reader'> &
  Choice2<'Reader'>

Added in v2.0.0

model

Reader (interface)

Signature

export interface Reader<R, A> {
  (r: R): A
}

Added in v2.0.0

utils

apS

Signature

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

Added in v2.8.0

apSW

Signature

export declare const apSW: <A, N extends string, Q, B>(
  name: Exclude<N, keyof A>,
  fb: Reader<Q, B>
) => <R>(fa: Reader<R, A>) => Reader<Q & R, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0

bind

Signature

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

Added in v2.8.0

bindTo

Signature

export declare const bindTo: <N extends string>(name: N) => <R, A>(fa: Reader<R, A>) => Reader<R, { [K in N]: A }>

Added in v2.8.0

bindW

Signature

export declare const bindW: <N extends string, A, Q, B>(
  name: Exclude<N, keyof A>,
  f: (a: A) => Reader<Q, B>
) => <R>(fa: Reader<R, A>) => Reader<Q & R, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0