@jsoldi/hkt
Version:
Higher kinded types for typescript and a few utility monads.
21 lines • 1.03 kB
TypeScript
import { IFunctorBase } from "./functor.js";
import { $, $I } from "../core/hkt.js";
import { Maybe } from "../types/maybe.js";
import { ITrivial } from "./monad.js";
import { IUnfold } from "./unfold.js";
import { TypeClassArg } from "./utilities.js";
/** The minimal definition of an unfoldable. */
export interface IUnfoldableBase<F> extends IFunctorBase<F> {
/** Unfolds new elements by applying the given function to a seed value. */
unfold<A, B>(alg: (b: B) => Maybe<[A, B]>): (b: B) => $<F, A>;
}
/** The unfoldable interface, where `scalar` is the trivial (identity) monad. */
export interface IUnfoldable<F> extends IUnfoldableBase<F>, IUnfold<F, $I> {
/** The trivial (identity) monad. */
readonly scalar: ITrivial;
}
declare const is_unfoldable: unique symbol;
/** Creates an `IUnfoldable` from an `IUnfoldableBase`. */
export declare function unfoldable<F>(base: TypeClassArg<IUnfoldableBase<F>, IUnfoldable<F>, typeof is_unfoldable>): IUnfoldable<F>;
export {};
//# sourceMappingURL=unfoldable.d.ts.map