Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Reader<E, A>

A Reader represents a computation which can read values from a shared environment. Computations are implemented as functions that take the environment (E) and return a value (A).

Adapted from fp-ts/Reader.

Type parameters

  • E

    The type representing the shared environment.

  • A

    The return value of the computation.

Hierarchy

  • Reader

Implements

Index

Properties

Methods

Properties

run

run: function

The wrapped computation.

Type declaration

    • (env: E): A
    • Parameters

      • env: E

      Returns A

Methods

apply

  • Unpacks a Reader with a return value that is a function from A to B into a function from Reader<E, A> to Reader<E, B>. Allows functions contained within a return value to transform a return value contained within a Reader.

    Type parameters

    • B

      The type of the transformed return value.

    Parameters

    Returns Reader<E, B>

compose

fmap

  • fmap<B>(func: function): Reader<E, B>
  • Bind a new computation to the Reader. Also known as flatMap.

    Type parameters

    • B

      The type of the transformed return value.

    Parameters

    • func: function

    Returns Reader<E, B>

local

  • local<E2>(func: function): Reader<E2, A>
  • Execute a computation in a modified environment.

    Type parameters

    • E2

    Parameters

    • func: function
        • (env: E2): E
        • Parameters

          • env: E2

          Returns E

    Returns Reader<E2, A>

map

  • map<B>(func: function): Reader<E, B>
  • Take a function that maps one type to another and lift it to work with Reader.

    Type parameters

    • B

      The type of the transformed return value.

    Parameters

    • func: function
        • (a: A): B
        • Parameters

          • a: A

          Returns B

    Returns Reader<E, B>

Static ask

  • Reads the current environment.

    Type parameters

    • E

    Returns Reader<E, E>

Static asks

  • asks<E, A>(func: function): Reader<E, A>
  • Projects a value from the global context in a Reader.

    Type parameters

    • E

    • A

    Parameters

    • func: function
        • (env: E): A
        • Parameters

          • env: E

          Returns A

    Returns Reader<E, A>

Static of

  • of<E, A>(a: A): Reader<E, A>
  • Create a new Reader that always returns the given value.

    Type parameters

    • E

    • A

    Parameters

    • a: A

    Returns Reader<E, A>

Generated using TypeDoc