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

    Interface Alternative<F>

    A functor with monoid-ish combine operation.

    All instances of the alternative functor a must satisfy the following laws:

    • Associativity: For all f, g and h; a.alt(a.alt(f)(g))(h) equals to a.alt(f)(a.alt(g)(h)),
    • Distributivity: For all f, g and x; a.apply(a.alt(f)(g))(x) equals to a.alt(a.apply(f)(x))(a.apply(g)(x)),
    • Left identity: For all f; a.alt(a.empty())(f) equals to f,
    • Right identity: For all f; a.alt(f)(a.empty()) equals to f,
    • Annihilation: For all f; a.apply(a.empty())(f) equals to a.empty().
    interface Alternative<F> {
        alt: <A>(first: Get1<F, A>) => (second: Get1<F, A>) => Get1<F, A>;
        apply: <T, U>(
            fn: Instance<Apply1<F, (t: T) => U>>,
        ) => (t: Instance<Apply1<F, T>>) => Instance<Apply1<F, U>>;
        empty: <A>() => Get1<F, A>;
        map: <T, U>(
            fn: (t: T) => U,
        ) => (t: Instance<Apply1<F, T>>) => Instance<Apply1<F, U>>;
        pure: <T>(t: T) => Instance<Apply1<F, T>>;
    }

    Type Parameters

    • F

    Hierarchy (View Summary)

    Index

    Properties

    Properties

    alt: <A>(first: Get1<F, A>) => (second: Get1<F, A>) => Get1<F, A>

    Picks the first successful computation.

    Type Declaration

      • <A>(first: Get1<F, A>): (second: Get1<F, A>) => Get1<F, A>
      • Type Parameters

        • A

        Parameters

        • first: Get1<F, A>

          The first computation to attempt.

        Returns (second: Get1<F, A>) => Get1<F, A>

        The first successful computation.

    apply: <T, U>(
        fn: Instance<Apply1<F, (t: T) => U>>,
    ) => (t: Instance<Apply1<F, T>>) => Instance<Apply1<F, U>>

    Applies the function to the value over S.

    Type Declaration

    empty: <A>() => Get1<F, A>

    Creates an empty erroneous computation that exits early.

    map: <T, U>(
        fn: (t: T) => U,
    ) => (t: Instance<Apply1<F, T>>) => Instance<Apply1<F, U>>

    Maps the function fn onto F structure.

    Type Declaration

    pure: <T>(t: T) => Instance<Apply1<F, T>>