Skip to content

Latest commit

 

History

History
750 lines (482 loc) · 11.8 KB

Reader.ts.md

File metadata and controls

750 lines (482 loc) · 11.8 KB
title nav_order parent
Reader.ts
77
Modules

Reader overview

Added in v2.0.0


Table of contents


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

apW

Less strict version of ap.

Signature

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

Added in v2.8.0

Category

id

Signature

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

Added in v2.0.0

Choice

left

Signature

export declare const left: <A, B, C>(pab: Reader<A, B>) => Reader<E.Either<A, C>, E.Either<B, C>>

Added in v2.10.0

right

Signature

export declare const right: <A, B, C>(pbc: Reader<B, C>) => Reader<E.Either<A, B>, E.Either<A, C>>

Added in v2.10.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

chainW

Less strict version of chain.

Signature

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

Added in v2.6.0

Pointed

of

Signature

export declare const of: <E, A>(a: A) => Reader<E, 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) => (fea: 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

Strong

first

Signature

export declare const first: <A, B, C>(pab: Reader<A, B>) => Reader<[A, C], [B, C]>

Added in v2.10.0

second

Signature

export declare const second: <A, B, C>(pab: Reader<B, C>) => Reader<[A, B], [A, C]>

Added in v2.10.0

combinators

apFirst

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

Derivable from Apply.

Signature

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

Added in v2.0.0

apFirstW

Less strict version of apFirst.

Signature

export declare const apFirstW: <R2, A, B>(second: Reader<R2, B>) => <R1>(first: Reader<R1, A>) => Reader<R1 & R2, A>

Added in v2.12.0

apSecond

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

Derivable from Apply.

Signature

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

Added in v2.0.0

apSecondW

Less strict version of apSecond.

Signature

export declare const apSecondW: <R2, A, B>(second: Reader<R2, B>) => <R1>(first: Reader<R1, A>) => Reader<R1 & R2, B>

Added in v2.12.0

asksReader

Effectfully accesses the environment.

Signature

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

Added in v2.11.0

asksReaderW

Less strict version of asksReader.

Signature

export declare const asksReaderW: <R1, R2, A>(f: (r1: R1) => Reader<R2, A>) => Reader<R1 & R2, A>

Added in v2.11.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, E, B>(f: (a: A) => Reader<E, B>) => (first: Reader<E, A>) => Reader<E, A>

Added in v2.0.0

chainFirstW

Less strict version of chainFirst.

Derivable from Chain.

Signature

export declare const chainFirstW: <R2, A, B>(
  f: (a: A) => Reader<R2, B>
) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, A>

Added in v2.11.0

flap

Derivable from Functor.

Signature

export declare const flap: <A>(a: A) => <E, B>(fab: Reader<E, (a: A) => B>) => Reader<E, B>

Added in v2.10.0

flatten

Derivable from Chain.

Signature

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

Added in v2.0.0

flattenW

Less strict version of flatten.

Signature

export declare const flattenW: <R1, R2, A>(mma: Reader<R1, Reader<R2, A>>) => Reader<R1 & R2, A>

Added in v2.11.0

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: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, 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

Apply

Signature

export declare const Apply: Apply2<'Reader'>

Added in v2.10.0

Category

Signature

export declare const Category: Category2<'Reader'>

Added in v2.7.0

Chain

Signature

export declare const Chain: Chain2<'Reader'>

Added in v2.10.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

Pointed

Signature

export declare const Pointed: Pointed2<'Reader'>

Added in v2.10.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

Use getApplicativeMonoid instead.

Signature

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

Added in v2.0.0

getSemigroup

Use getApplySemigroup instead.

Signature

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

Added in v2.0.0

reader

Use small, specific instances instead.

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

ApT

Signature

export declare const ApT: Reader<unknown, readonly []>

Added in v2.11.0

Do

Signature

export declare const Do: Reader<unknown, {}>

Added in v2.9.0

apS

Signature

export declare const apS: <N, A, E, B>(
  name: Exclude<N, keyof A>,
  fb: Reader<E, B>
) => (fa: Reader<E, A>) => Reader<E, { readonly [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, R2, B>(
  name: Exclude<N, keyof A>,
  fb: Reader<R2, B>
) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>

Added in v2.8.0

bind

Signature

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

Added in v2.8.0

bindTo

Signature

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

Added in v2.8.0

bindW

Signature

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

Added in v2.8.0

sequenceArray

Signature

export declare const sequenceArray: <R, A>(arr: readonly Reader<R, A>[]) => Reader<R, readonly A[]>

Added in v2.9.0

traverseArray

Signature

export declare const traverseArray: <R, A, B>(
  f: (a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.9.0

traverseArrayWithIndex

Signature

export declare const traverseArrayWithIndex: <R, A, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.9.0

traverseReadonlyArrayWithIndex

Equivalent to ReadonlyArray#traverseWithIndex(Applicative).

Signature

export declare const traverseReadonlyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: readonly A[]) => Reader<R, readonly B[]>

Added in v2.11.0

traverseReadonlyNonEmptyArrayWithIndex

Equivalent to ReadonlyNonEmptyArray#traverseWithIndex(Applicative).

Signature

export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(
  f: (index: number, a: A) => Reader<R, B>
) => (as: ReadonlyNonEmptyArray<A>) => Reader<R, ReadonlyNonEmptyArray<B>>

Added in v2.11.0