@mikuroxina/mini-fn
    Preparing search index...

    Type Alias CatT<M, CTX>

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

    type CatT<M, CTX> = {
        addM: <const K extends PropertyKey, A>(
            key: K,
            value: Get1<M, A>,
        ) => CatT<M, Record<K, A> & CTX>;
        addMWith: <const K extends PropertyKey, A>(
            key: K,
            fn: (ctx: CTX) => Get1<M, A>,
        ) => CatT<M, Record<K, A> & CTX>;
        addWith: <const K extends PropertyKey, A>(
            key: K,
            fn: (ctx: CTX) => A,
        ) => CatT<M, Record<K, A> & CTX>;
        ctx: Get1<M, CTX>;
        finish: <R>(fn: (ctx: CTX) => R) => Get1<M, R>;
        finishM: <R>(fn: (ctx: CTX) => Get1<M, R>) => Get1<M, R>;
        loop: <S>(
            initState: S,
            body: (state: S, ctx: CTX) => Get1<M, ControlFlow.ControlFlow<never[], S>>,
        ) => CatT<M, CTX>;
        monad: TypeClass.Monad.Monad<M>;
        run: (computation: Get1<M, never[]>) => CatT<M, CTX>;
        runWith: (computation: (ctx: CTX) => Get1<M, never[]>) => CatT<M, CTX>;
        when: (
            cond: (ctx: CTX) => boolean,
            computation: (ctx: CTX) => Get1<M, never[]>,
        ) => CatT<M, CTX>;
        while: (
            cond: (ctx: CTX) => Get1<M, boolean>,
            body: (ctx: CTX) => Get1<M, never[]>,
        ) => CatT<M, CTX>;
    }

    Type Parameters

    • M

      Monad implementation which wraps ctx.

    • CTX

      Passing context type.

    Index

    Properties

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

    Binds a new value wrapped by the monad.

    Type Declaration

      • <const K extends PropertyKey, A>(
            key: K,
            value: Get1<M, A>,
        ): CatT<M, Record<K, A> & CTX>
      • 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 extends PropertyKey, A>(
        key: K,
        fn: (ctx: CTX) => Get1<M, A>,
    ) => CatT<M, Record<K, A> & CTX>

    Binds a new value wrapped by the monad, calculated from ctx by fn.

    Type Declaration

      • <const K extends PropertyKey, A>(
            key: K,
            fn: (ctx: CTX) => Get1<M, A>,
        ): CatT<M, Record<K, A> & CTX>
      • Type Parameters

        • const K extends PropertyKey
        • A

        Parameters

        • key: K

          The new property key for context

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

          The calculation which returns the wrapped value.

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

        A new CatT containing the value at the key.

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

    Appends a new value calculated from ctx by fn.

    Type Declaration

      • <const K extends PropertyKey, A>(
            key: K,
            fn: (ctx: CTX) => A,
        ): CatT<M, Record<K, A> & CTX>
      • Type Parameters

        • const K extends PropertyKey
        • A

        Parameters

        • key: K

          The new property key for context

        • fn: (ctx: CTX) => A

          The calculation.

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

        A new CatT containing the value at the key.

    ctx: Get1<M, CTX>

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

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

    Reduces the context into a value by fn.

    Type Declaration

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

        • R

        Parameters

        • fn: (ctx: CTX) => R

          The finishing computation.

        Returns Get1<M, R>

        A reduced value.

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

    Reduces the context into a value on M by fn.

    Type Declaration

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

        • R

        Parameters

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

          The finishing computation.

        Returns Get1<M, R>

        A reduced value on M.

    loop: <S>(
        initState: S,
        body: (state: S, ctx: CTX) => Get1<M, ControlFlow.ControlFlow<never[], S>>,
    ) => CatT<M, CTX>

    Runs a looping computation while it returns Continue<S>.

    Type Declaration

    The Monad instance for M.

    run: (computation: Get1<M, never[]>) => CatT<M, CTX>

    Runs the computation.

    Type Declaration

      • (computation: Get1<M, never[]>): CatT<M, CTX>
      • Parameters

        • computation: Get1<M, never[]>

          The computation to run.

        Returns CatT<M, CTX>

        A new CatT with modified environment.

    runWith: (computation: (ctx: CTX) => Get1<M, never[]>) => CatT<M, CTX>

    Runs the computation with the context.

    Type Declaration

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

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

          The computation to run.

        Returns CatT<M, CTX>

        A new CatT with modified environment.

    when: (
        cond: (ctx: CTX) => boolean,
        computation: (ctx: CTX) => Get1<M, never[]>,
    ) => CatT<M, CTX>

    Runs a computation if only cond is satisfied.

    Type Declaration

      • (
            cond: (ctx: CTX) => boolean,
            computation: (ctx: CTX) => Get1<M, never[]>,
        ): CatT<M, CTX>
      • Parameters

        • cond: (ctx: CTX) => boolean

          A condition function.

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

          A monadic operation used only if cond returns true.

        Returns CatT<M, CTX>

        A new CatT with modified environment.

    while: (
        cond: (ctx: CTX) => Get1<M, boolean>,
        body: (ctx: CTX) => Get1<M, never[]>,
    ) => CatT<M, CTX>

    Runs a looping computation while cond returns true.

    Type Declaration

      • (
            cond: (ctx: CTX) => Get1<M, boolean>,
            body: (ctx: CTX) => Get1<M, never[]>,
        ): CatT<M, CTX>
      • Parameters

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

          A function to decide to continue the loop.

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

          A computation to run.

        Returns CatT<M, CTX>

        A new CatT with modified environment.