Interface CatT<M, CTX>

Contains a ctx and can be transformed into another one by some methods.

Type Parameters

  • M

    Monad implementation which wraps ctx.

  • CTX

    Passing context type.

Hierarchy

  • CatT

Properties

addM: (<const K, A>(key, value) => CatT<M, Record<K, A> & CTX>)

Type declaration

    • <const K, A>(key, value): CatT<M, Record<K, A> & CTX>
    • Binds a new value wrapped by the monad.

      Type Parameters

      • const K extends PropertyKey

      • A

      Parameters

      • key: K

        The new property key for context

      • value: Get1<M, A>

        The wrapped value to bind.

      Returns CatT<M, Record<K, A> & CTX>

      A new CatT containing the value at the key.

addMWith: (<const K, A>(key, fn) => CatT<M, Record<K, A> & CTX>)

Type declaration

    • <const K, A>(key, fn): CatT<M, Record<K, A> & CTX>
    • Binds a new value wrapped by the monad, calculated from ctx by fn.

      Type Parameters

      • const K extends PropertyKey

      • A

      Parameters

      • key: K

        The new property key for context

      • fn: ((ctx) => Get1<M, A>)

        The calculation which returns the wrapped value.

          • (ctx): Get1<M, A>
          • Parameters

            • ctx: CTX

            Returns Get1<M, A>

      Returns CatT<M, Record<K, A> & CTX>

      A new CatT containing the value at the key.

addWith: (<const K, A>(key, fn) => CatT<M, Record<K, A> & CTX>)

Type declaration

    • <const K, A>(key, fn): CatT<M, Record<K, A> & CTX>
    • Appends a new value calculated from ctx by fn.

      Type Parameters

      • const K extends PropertyKey

      • A

      Parameters

      • key: K

        The new property key for context

      • fn: ((ctx) => A)

        The calculation.

          • (ctx): A
          • Parameters

            • ctx: CTX

            Returns A

      Returns CatT<M, Record<K, A> & CTX>

      A new CatT containing the value at the key.

ctx: Instance<Apply1<M, CTX>>

Contained context. Altering an interior value must be abstained, or may occurs unsound behaviors.

finish: (<R>(fn) => Get1<M, R>)

Type declaration

    • <R>(fn): Get1<M, R>
    • Reduces the context into a value by fn.

      Type Parameters

      • R

      Parameters

      • fn: ((ctx) => R)

        The finishing computation.

          • (ctx): R
          • Parameters

            • ctx: CTX

            Returns R

      Returns Get1<M, R>

      A reduced value.

finishM: (<R>(fn) => Get1<M, R>)

Type declaration

    • <R>(fn): Get1<M, R>
    • Reduces the context into a value on M by fn.

      Type Parameters

      • R

      Parameters

      • fn: ((ctx) => Get1<M, R>)

        The finishing computation.

          • (ctx): Get1<M, R>
          • Parameters

            • ctx: CTX

            Returns Get1<M, R>

      Returns Get1<M, R>

      A reduced value on M.

foreach: (<T>(iter, body) => CatT<M, CTX>)

Type declaration

    • <T>(iter, body): CatT<M, CTX>
    • Runs a looping computation with items from the list.

      Type Parameters

      • T

      Parameters

      • iter: List<T>

        A list to be iterated.

      • body: ((item, ctx) => Get1<M, never[]>)

        A computation to run.

          • (item, ctx): Get1<M, never[]>
          • Parameters

            • item: T
            • ctx: CTX

            Returns Get1<M, never[]>

      Returns CatT<M, CTX>

      A new CatT with modified environment.

loop: (<S>(initState, body) => CatT<M, CTX>)

Type declaration

    • <S>(initState, body): CatT<M, CTX>
    • Runs a looping computation while it returns Continue<S>.

      Type Parameters

      • S

      Parameters

      Returns CatT<M, CTX>

      A new CatT with modified environment.

monad: Monad<M>

The Monad instance for M.

run: ((computation) => CatT<M, CTX>)

Type declaration

    • (computation): CatT<M, CTX>
    • Runs the computation.

      Parameters

      • computation: Get1<M, never[]>

        The computation to run.

      Returns CatT<M, CTX>

      A new CatT with modified environment.

runWith: ((computation) => CatT<M, CTX>)

Type declaration

    • (computation): CatT<M, CTX>
    • Runs the computation with the context.

      Parameters

      • computation: ((ctx) => Get1<M, never[]>)

        The computation to run.

          • (ctx): Get1<M, never[]>
          • Parameters

            • ctx: CTX

            Returns Get1<M, never[]>

      Returns CatT<M, CTX>

      A new CatT with modified environment.

when: ((cond, computation) => CatT<M, CTX>)

Type declaration

    • (cond, computation): CatT<M, CTX>
    • Runs a computation if only cond is satisfied.

      Parameters

      • cond: ((ctx) => boolean)

        A condition function.

          • (ctx): boolean
          • Parameters

            • ctx: CTX

            Returns boolean

      • computation: ((ctx) => Get1<M, never[]>)

        A monadic operation used only if cond returns true.

          • (ctx): Get1<M, never[]>
          • Parameters

            • ctx: CTX

            Returns Get1<M, never[]>

      Returns CatT<M, CTX>

      A new CatT with modified environment.

while: ((cond, body) => CatT<M, CTX>)

Type declaration

    • (cond, body): CatT<M, CTX>
    • Runs a looping computation while cond returns true.

      Parameters

      • cond: ((ctx) => Get1<M, boolean>)

        A function to decide to continue the loop.

          • (ctx): Get1<M, boolean>
          • Parameters

            • ctx: CTX

            Returns Get1<M, boolean>

      • body: ((ctx) => Get1<M, never[]>)

        A computation to run.

          • (ctx): Get1<M, never[]>
          • Parameters

            • ctx: CTX

            Returns Get1<M, never[]>

      Returns CatT<M, CTX>

      A new CatT with modified environment.

Generated using TypeDoc