@jsoldi/hkt
Version:
Higher kinded types for typescript and a few utility monads.
27 lines • 1.22 kB
TypeScript
import { ITypeClass, $, $B2, $K1 } from "../core/hkt.js";
import { TypeClassArg } from "./utilities.js";
/** The minimal definition of a functor. */
export interface IFunctorBase<F> extends ITypeClass<F> {
/** Maps a function over a functor. */
map: <A, B>(fa: $<F, A>, f: (a: A) => B) => $<F, B>;
}
/** The functor interface, providing a set of functions for working with functors. */
export interface IFunctor<F> extends IFunctorBase<F> {
/** Maps a function over a functor. */
fmap<A, B>(f: (a: A) => B): (fa: $<F, A>) => $<F, B>;
/** Nests a functor within another functor. */
nestFunctor<G>(g: IFunctorBase<G>): IFunctor<$B2<F, G>>;
}
declare const is_functor: unique symbol;
export type FunctorArg<F> = TypeClassArg<IFunctorBase<F>, IFunctor<F>, typeof is_functor>;
/** The functor factory. */
export interface IFunctorFactory {
/** Creates an `IFunctor` from an `IFunctorBase`. */
<F>(base: FunctorArg<F>): IFunctor<F>;
/** Creates an identity `IFunctor`. */
const<A>(): IFunctor<$K1<A>>;
}
/** The functor factory, providing a set of functions for working with functors. */
export declare const functor: IFunctorFactory;
export {};
//# sourceMappingURL=functor.d.ts.map