213 lines
3.2 KiB
JavaScript
213 lines
3.2 KiB
JavaScript
export default {}
|
|
|
|
/**
|
|
* @template T, R
|
|
* @typedef {(value: T) => R} Morphism
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {<R>(value: T) => R} InferredMorphism
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {(value: T) => boolean} Predicate
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
equals: (b: Setoid<T>) => boolean
|
|
* }} Setoid
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
lte: (b: Ord<T>) => boolean
|
|
* }} Ord
|
|
*/
|
|
|
|
/**
|
|
* @template T, U
|
|
* @typedef {*} Semigroupoid
|
|
*/
|
|
|
|
/**
|
|
* @template I, J
|
|
* @typedef {{
|
|
compose: <K>(b: Semigroupoid<J, K>) => Semigroupoid<I, K>
|
|
* }} Category
|
|
*/
|
|
|
|
/**
|
|
* @template T, U
|
|
* @template {Category<T, U>} M
|
|
* @typedef {{
|
|
id: () => (value: T) => M
|
|
* }} CategoryTypeRef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
concat: (b: Semigroup<T>) => Semigroup<T>
|
|
* }} Semigroup
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef{Semigroup<T>} Monoid
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @template {Monoid<T>} M
|
|
* @typedef {{
|
|
empty: () => M
|
|
* }} MonoidTypeRef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Monoid<T> &
|
|
{ invert: () => Group<T> }
|
|
* } Group
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
filter: <U>(f: (acc: U, val: T) => U, init: U) => U
|
|
* }} Filterable
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
map: <U>(f: Morphism<T, U>) => Functor<U>
|
|
* }} Functor
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
contramap: <U>(f: Morphism<U, T>) => Contravariant<T>
|
|
* }} Contravariant
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
ap: <U>(f: Apply<Morphism<T, U>>) => Apply<U>
|
|
* }} Apply
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
ap: <U>(b: Applicative<Morphism<U, T>>) => Applicative<T>,
|
|
map: <U>(f: Morphism<T, U>) => Applicative<U>
|
|
* }} Applicative
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @template {Applicative<T>} M
|
|
* @typedef {{
|
|
of: (value: T) => M
|
|
* }} ApplicativeTypeRef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Functor<T> &
|
|
{ alt: (b: Alt<T>) => Alt<T> }
|
|
* } Alt
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {Alt<T>} Plus
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @template {Plus<T>} M
|
|
* @typedef {
|
|
Alt<T> &
|
|
{ zero: () => M }
|
|
* } PlusTypeRef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {Applicative<T> & Plus<T>} Alternative
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @template {Applicative<T> & Plus<T>} M
|
|
* @typedef {ApplicativeTypeRef<T, M> & PlusTypeRef<T, M>} AlternativeTypeRef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {{
|
|
filter: <U>(f: (acc: U, val: T) => U, init: U) => U
|
|
* }} Foldable
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Functor<T> & Foldable<T> &
|
|
{ traverse: <U>(A: ApplicativeTypeRef<U, Applicative<U>>, f: (val: T) => Applicative<U>) => Applicative<Traversable<U>> }
|
|
* } Traversable
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Apply<T> &
|
|
{ chain: <U>(f: (value: T) => Chain<U>) => Chain<U> }
|
|
* } Chain
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {Chain<T>} ChainRec
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {Functor<T> & Applicative<T> & Chain<T>} Monad
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @template {Monad<T>} M
|
|
* @typedef {ApplicativeTypeRef<T, M>} MonadTypeDef
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Functor<T> &
|
|
{ extend: <U>(f: (val: Extend<T>) => U) => Extend<U>}
|
|
* } Extend
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {
|
|
Extend<T> &
|
|
{ extract: () => T }
|
|
* } Comonad<T>
|
|
*/
|
|
|
|
/** @typedef {(...args: any[]) => any} Fn */
|
|
|