@fp-ts/core
Advanced tools
Comparing version 0.0.3 to 0.0.4
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Functor } from "@fp-ts/core/Functor"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -15,3 +15,3 @@ export interface Bifunctor<F extends TypeLambda> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -22,3 +22,3 @@ export declare const mapLeft: <F extends TypeLambda>(Bifunctor: Bifunctor<F>) => <E, G>(f: (e: E) => G) => <S, R, O, A>(self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, G, A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -29,5 +29,5 @@ export declare const map: <F extends TypeLambda>(Bifunctor: Bifunctor<F>) => <A, B>(f: (a: A) => B) => <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, B>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const mapBothComposition: <F extends TypeLambda, G extends TypeLambda>(FunctorF: Functor<F>, BifunctorG: Bifunctor<G>) => <GE, GG, A, B>(f: (e: GE) => GG, g: (a: A) => B) => <FS, FR, FO, FE, GS, GR, GO>(self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GG, B>>; | ||
//# sourceMappingURL=Bifunctor.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -18,3 +18,3 @@ const mapLeft = Bifunctor => f => Bifunctor.mapBoth(f, _Function.identity); | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -25,7 +25,7 @@ | ||
const map = Bifunctor => f => Bifunctor.mapBoth(e => e, f); | ||
const map = Bifunctor => f => Bifunctor.mapBoth(_Function.identity, f); | ||
/** | ||
* Returns a default `mapBoth` composition. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -32,0 +32,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import * as compare from "@fp-ts/core/Sortable"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,3 +17,3 @@ export interface Bounded<A> extends Sortable<A> { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -24,3 +24,3 @@ export declare const fromSortable: <A>(Sortable: compare.Sortable<A>, maximum: A, minimum: A) => Bounded<A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,5 +31,5 @@ export declare const clamp: <A>(B: Bounded<A>) => (a: A) => A; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const reverse: <A>(Bounded: Bounded<A>) => Bounded<A>; | ||
//# sourceMappingURL=Bounded.d.ts.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -21,3 +21,3 @@ | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,3 +31,3 @@ const fromSortable = (Sortable, maximum, minimum) => ({ ...Sortable, | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -42,3 +42,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -45,0 +45,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Composable } from "@fp-ts/core/Composable"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Category<F extends TypeLambda> extends Composable<F> { |
/** | ||
* Kleisli categories. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ import type { ComposableKind } from "@fp-ts/core/ComposableKind"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -13,0 +13,0 @@ export interface CategoryKind<F extends TypeLambda> extends ComposableKind<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Extendable } from "@fp-ts/core/Extendable"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Comonad<F extends TypeLambda> extends Extendable<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,3 +7,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ export interface Composable<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,3 +7,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ export interface ComposableKind<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,3 +7,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ export interface Contravariant<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Functor } from "@fp-ts/core/Functor"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Extendable<F extends TypeLambda> extends Functor<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { ComposableKind } from "@fp-ts/core/ComposableKind"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,3 +20,3 @@ export interface FlatMap<M extends TypeLambda> extends Functor<M> { | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -28,3 +28,3 @@ export declare const zipLeft: <F extends TypeLambda>(FlatMap: FlatMap<F>) => <S, R2, O2, E2>(that: Kind<F, S, R2, O2, E2, unknown>) => <R1, O1, E1, A>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, A>; | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -34,7 +34,7 @@ export declare const zipRight: <F extends TypeLambda>(FlatMap: FlatMap<F>) => <S, R2, O2, E2, A>(that: Kind<F, S, R2, O2, E2, A>) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, unknown>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, A>; | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const bind: <M extends TypeLambda>(FlatMap: FlatMap<M>) => <N extends string, A extends object, S, R2, O2, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => Kind<M, S, R2, O2, E2, B>) => <R1, O1, E1>(self: Kind<M, S, R1, O1, E1, A>) => Kind<M, S, R1 & R2, O2 | O1, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -45,5 +45,5 @@ export declare const composeKind: <F extends TypeLambda>(FlatMap: FlatMap<F>) => <B, S, R2, O2, E2, C>(bfc: (b: B) => Kind<F, S, R2, O2, E2, C>) => <A, R1, O1, E1>(afb: (a: A) => Kind<F, S, R1, O1, E1, B>) => (a: A) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, C>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const tap: <F extends TypeLambda>(FlatMap: FlatMap<F>) => <A, S, R2, O2, E2>(f: (a: A) => Kind<F, S, R2, O2, E2, unknown>) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, A>; | ||
//# sourceMappingURL=FlatMap.d.ts.map |
@@ -15,10 +15,5 @@ "use strict"; | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const zipLeft = FlatMap => { | ||
const tap_ = tap(FlatMap); | ||
return that => { | ||
return tap_(() => that); | ||
}; | ||
}; | ||
const zipLeft = FlatMap => that => tap(FlatMap)(() => that); | ||
/** | ||
@@ -28,3 +23,3 @@ * A variant of `flatMap` that ignores the value produced by this effect. | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -35,10 +30,6 @@ | ||
const zipRight = FlatMap => { | ||
return that => { | ||
return FlatMap.flatMap(() => that); | ||
}; | ||
}; | ||
const zipRight = FlatMap => that => FlatMap.flatMap(() => that); | ||
/** | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -53,3 +44,3 @@ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -64,3 +55,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -67,0 +58,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -16,5 +16,9 @@ export interface Foldable<F extends TypeLambda> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArrayWith: <F extends TypeLambda>(Foldable: Foldable<F>) => <S, R, O, E, A, B>(self: Kind<F, S, R, O, E, A>, f: (a: A) => B) => readonly B[]; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const foldMap: <F extends TypeLambda>(Foldable: Foldable<F>) => <M>(Monoid: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => M; | ||
//# sourceMappingURL=Foldable.d.ts.map |
@@ -6,14 +6,25 @@ "use strict"; | ||
}); | ||
exports.foldMap = void 0; | ||
exports.toReadonlyArrayWith = exports.foldMap = void 0; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const foldMap = Foldable => Monoid => f => Foldable.reduce(Monoid.empty, (m, a) => Monoid.combine(m, f(a))); | ||
const toReadonlyArrayWith = Foldable => (self, f) => Foldable.reduce([], (out, a) => { | ||
out.push(f(a)); | ||
return out; | ||
})(self); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.toReadonlyArrayWith = toReadonlyArrayWith; | ||
const foldMap = Foldable => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(Foldable)(self, f)); | ||
exports.foldMap = foldMap; | ||
//# sourceMappingURL=Foldable.js.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -16,5 +16,9 @@ export interface FoldableWithIndex<F extends TypeLambda, I> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArrayWith: <F extends TypeLambda, I>(FoldableWithIndex: FoldableWithIndex<F, I>) => <S, R, O, E, A, B>(self: Kind<F, S, R, O, E, A>, f: (a: A, i: I) => B) => readonly B[]; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const foldMapWithIndex: <F extends TypeLambda, I>(FoldableWithIndex: FoldableWithIndex<F, I>) => <M>(Monoid: Monoid<M>) => <A>(f: (a: A, i: I) => M) => <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => M; | ||
//# sourceMappingURL=FoldableWithIndex.d.ts.map |
@@ -6,14 +6,25 @@ "use strict"; | ||
}); | ||
exports.foldMapWithIndex = void 0; | ||
exports.toReadonlyArrayWith = exports.foldMapWithIndex = void 0; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const foldMapWithIndex = FoldableWithIndex => Monoid => f => FoldableWithIndex.reduceWithIndex(Monoid.empty, (m, a, i) => Monoid.combine(m, f(a, i))); | ||
const toReadonlyArrayWith = FoldableWithIndex => (self, f) => FoldableWithIndex.reduceWithIndex([], (out, a, i) => { | ||
out.push(f(a, i)); | ||
return out; | ||
})(self); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.toReadonlyArrayWith = toReadonlyArrayWith; | ||
const foldMapWithIndex = FoldableWithIndex => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(self, f)); | ||
exports.foldMapWithIndex = foldMapWithIndex; | ||
//# sourceMappingURL=FoldableWithIndex.js.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,3 +7,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -16,3 +16,3 @@ export interface Functor<F extends TypeLambda> extends TypeClass<F> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -22,3 +22,3 @@ export declare const mapComposition: <F extends TypeLambda, G extends TypeLambda>(FunctorF: Functor<F>, FunctorG: Functor<G>) => <A, B>(f: (a: A) => B) => <FS, FR, FO, FE, GS, GR, GO, GE>(self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, B>>; | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -28,3 +28,3 @@ export declare const flap: <F extends TypeLambda>(Functor: Functor<F>) => <A>(a: A) => <S, R, O, E, B>(self: Kind<F, S, R, O, E, (a: A) => B>) => Kind<F, S, R, O, E, B>; | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -34,3 +34,3 @@ export declare const as: <F extends TypeLambda>(Functor: Functor<F>) => <B>(b: B) => <S, R, O, E>(self: Kind<F, S, R, O, E, unknown>) => Kind<F, S, R, O, E, B>; | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -40,3 +40,3 @@ export declare const unit: <F extends TypeLambda>(Functor: Functor<F>) => <S, R, O, E>(self: Kind<F, S, R, O, E, unknown>) => Kind<F, S, R, O, E, void>; | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -48,3 +48,3 @@ export declare const bindTo: <F extends TypeLambda>(Functor: Functor<F>) => <N extends string>(name: N) => <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, { readonly [K in N]: A; }>; | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -54,5 +54,5 @@ let_ as let }; | ||
* @category tuple sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const tupled: <F extends TypeLambda>(Functor: Functor<F>) => <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, readonly [A]>; | ||
//# sourceMappingURL=Functor.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,3 +17,3 @@ const mapComposition = (FunctorF, FunctorG) => f => FunctorF.map(FunctorG.map(f)); | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -27,3 +27,3 @@ | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -37,3 +37,3 @@ | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -50,3 +50,3 @@ | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -63,7 +63,5 @@ | ||
const let_ = F => { | ||
return (name, f) => F.map(a => Object.assign({}, a, { | ||
[name]: f(a) | ||
})); | ||
}; | ||
const let_ = F => (name, f) => F.map(a => Object.assign({}, a, { | ||
[name]: f(a) | ||
})); | ||
@@ -78,3 +76,3 @@ exports.let = let_; | ||
* @category tuple sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -81,0 +79,0 @@ const tupled = Functor => Functor.map(a => [a]); |
10
HKT.d.ts
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const URI: unique symbol; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -15,3 +15,3 @@ export interface TypeClass<F extends TypeLambda> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,3 +26,3 @@ export interface TypeLambda { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -29,0 +29,0 @@ export declare type Kind<F extends TypeLambda, InOut1, In1, Out3, Out2, Out1> = F extends { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -24,8 +24,7 @@ import * as bifunctor from "@fp-ts/core/Bifunctor"; | ||
import * as ordering from "@fp-ts/core/Ordering"; | ||
import * as pointed from "@fp-ts/core/Pointed"; | ||
import * as semigroup from "@fp-ts/core/Semigroup"; | ||
import * as semigroupal from "@fp-ts/core/Semigroupal"; | ||
import * as semigroupKind from "@fp-ts/core/SemigroupKind"; | ||
import * as show from "@fp-ts/core/Show"; | ||
import * as sortable from "@fp-ts/core/Sortable"; | ||
import * as succeed from "@fp-ts/core/Succeed"; | ||
import * as traversable from "@fp-ts/core/Traversable"; | ||
@@ -36,3 +35,3 @@ import * as traversableWithIndex from "@fp-ts/core/TraversableWithIndex"; | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -42,3 +41,3 @@ bifunctor, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -48,3 +47,3 @@ bounded, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -54,3 +53,3 @@ category, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -60,3 +59,3 @@ categoryKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -66,3 +65,3 @@ comonad, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -72,3 +71,3 @@ composable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -78,3 +77,3 @@ composableKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -84,3 +83,3 @@ contravariant, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -90,3 +89,3 @@ extendable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -96,3 +95,3 @@ flatMap, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -102,3 +101,3 @@ foldable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -108,7 +107,7 @@ foldableWithIndex, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
functor, | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -118,3 +117,3 @@ hkt, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -124,3 +123,3 @@ invariant, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -130,3 +129,3 @@ monad, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -136,3 +135,3 @@ monoid, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -142,3 +141,3 @@ monoidal, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -148,3 +147,3 @@ monoidKind, | ||
* @category data types | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -154,8 +153,13 @@ ordering, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
pointed, | ||
/** | ||
* @category type classes | ||
* @since 1.0.0 | ||
*/ | ||
semigroup, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -165,3 +169,3 @@ semigroupal, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -171,25 +175,15 @@ semigroupKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
show, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
*/ | ||
sortable, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
succeed, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
*/ | ||
traversable, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
traversableWithIndex }; | ||
//# sourceMappingURL=index.d.ts.map |
14
index.js
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.traversableWithIndex = exports.traversable = exports.succeed = exports.sortable = exports.show = exports.semigroupal = exports.semigroupKind = exports.semigroup = exports.ordering = exports.monoidal = exports.monoidKind = exports.monoid = exports.monad = exports.invariant = exports.hkt = exports.functor = exports.foldableWithIndex = exports.foldable = exports.flatMap = exports.extendable = exports.contravariant = exports.composableKind = exports.composable = exports.comonad = exports.categoryKind = exports.category = exports.bounded = exports.bifunctor = void 0; | ||
exports.traversableWithIndex = exports.traversable = exports.sortable = exports.semigroupal = exports.semigroupKind = exports.semigroup = exports.pointed = exports.ordering = exports.monoidal = exports.monoidKind = exports.monoid = exports.monad = exports.invariant = exports.hkt = exports.functor = exports.foldableWithIndex = exports.foldable = exports.flatMap = exports.extendable = exports.contravariant = exports.composableKind = exports.composable = exports.comonad = exports.categoryKind = exports.category = exports.bounded = exports.bifunctor = void 0; | ||
@@ -89,2 +89,6 @@ var bifunctor = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Bifunctor")); | ||
var pointed = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Pointed")); | ||
exports.pointed = pointed; | ||
var semigroup = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Semigroup")); | ||
@@ -102,6 +106,2 @@ | ||
var show = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Show")); | ||
exports.show = show; | ||
var sortable = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Sortable")); | ||
@@ -111,6 +111,2 @@ | ||
var succeed = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Succeed")); | ||
exports.succeed = succeed; | ||
var traversable = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Traversable")); | ||
@@ -117,0 +113,0 @@ |
/** | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -5,0 +5,0 @@ export declare function pipe<A, B>(a: A, ab: (a: A) => B): B; |
@@ -11,3 +11,3 @@ "use strict"; | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,3 +17,3 @@ | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,0 +20,0 @@ const identity = a => a; |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,3 +7,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,0 +10,0 @@ export interface Invariant<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
import type { FlatMap } from "@fp-ts/core/FlatMap"; | ||
import type { TypeLambda } from "@fp-ts/core/HKT"; | ||
import type { Succeed } from "@fp-ts/core/Succeed"; | ||
import type { Pointed } from "@fp-ts/core/Pointed"; | ||
/** | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Monad<F extends TypeLambda> extends Succeed<F>, FlatMap<F> { | ||
export interface Monad<F extends TypeLambda> extends Pointed<F>, FlatMap<F> { | ||
} | ||
//# sourceMappingURL=Monad.d.ts.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Bounded } from "@fp-ts/core/Bounded"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,3 +17,3 @@ export interface Monoid<A> extends Semigroup<A> { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -27,3 +27,3 @@ export declare const fromSemigroup: <A>(Semigroup: Semigroup<A>, empty: A) => Monoid<A>; | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -37,3 +37,3 @@ export declare const min: <A>(Bounded: Bounded<A>) => Monoid<A>; | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -44,3 +44,3 @@ export declare const max: <A>(Bounded: Bounded<A>) => Monoid<A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -51,3 +51,3 @@ export declare const reverse: <A>(Monoid: Monoid<A>) => Monoid<A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -58,5 +58,5 @@ export declare const struct: <A>(monoids: { [K in keyof A]: Monoid<A[K]>; }) => Monoid<{ readonly [K_1 in keyof A]: A[K_1]; }>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const tuple: <A extends readonly unknown[]>(...monoids: { [K in keyof A]: Monoid<A[K]>; }) => Monoid<Readonly<A>>; | ||
//# sourceMappingURL=Monoid.d.ts.map |
@@ -16,7 +16,7 @@ "use strict"; | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const fromSemigroup = (Semigroup, empty) => ({ ...Semigroup, | ||
empty, | ||
combineAll: collection => Semigroup.combineMany(empty, collection) | ||
combineAll: collection => Semigroup.combineMany(collection)(empty) | ||
}); | ||
@@ -29,3 +29,3 @@ /** | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -43,3 +43,3 @@ | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -54,3 +54,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -65,3 +65,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -86,3 +86,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -89,0 +89,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
import type { Kind, TypeLambda } from "@fp-ts/core/HKT"; | ||
import type { Monoid } from "@fp-ts/core/Monoid"; | ||
import type { Pointed } from "@fp-ts/core/Pointed"; | ||
import type { Semigroupal } from "@fp-ts/core/Semigroupal"; | ||
import type { Succeed } from "@fp-ts/core/Succeed"; | ||
/** | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Monoidal<F extends TypeLambda> extends Semigroupal<F>, Succeed<F> { | ||
/** sequence */ | ||
export interface Monoidal<F extends TypeLambda> extends Semigroupal<F>, Pointed<F> { | ||
readonly zipAll: <S, R, O, E, A>(collection: Iterable<Kind<F, S, R, O, E, A>>) => Kind<F, S, R, O, E, ReadonlyArray<A>>; | ||
@@ -19,5 +18,5 @@ } | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const liftMonoid: <F extends TypeLambda>(Monoidal: Monoidal<F>) => <A, S, R, O, E>(Monoid: Monoid<A>) => Monoid<Kind<F, S, R, O, E, A>>; | ||
//# sourceMappingURL=Monoidal.d.ts.map |
@@ -19,7 +19,7 @@ "use strict"; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const liftMonoid = Monoidal => Monoid => monoid.fromSemigroup(semigroupal.liftSemigroup(Monoidal)(Monoid), Monoidal.succeed(Monoid.empty)); | ||
const liftMonoid = Monoidal => Monoid => monoid.fromSemigroup(semigroupal.liftSemigroup(Monoidal)(Monoid), Monoidal.of(Monoid.empty)); | ||
exports.liftMonoid = liftMonoid; | ||
//# sourceMappingURL=Monoidal.js.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -19,5 +19,5 @@ export interface MonoidKind<F extends TypeLambda> extends SemigroupKind<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const fromSemigroupKind: <F extends TypeLambda>(SemigroupKind: SemigroupKind<F>, emptyKind: <S>() => Kind<F, S, unknown, never, never, never>) => MonoidKind<F>; | ||
//# sourceMappingURL=MonoidKind.d.ts.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -15,3 +15,3 @@ const fromSemigroupKind = (SemigroupKind, emptyKind) => { | ||
emptyKind, | ||
combineKindAll: collection => SemigroupKind.combineKindMany(emptyKind(), collection) | ||
combineKindAll: collection => SemigroupKind.combineKindMany(collection)(emptyKind()) | ||
}; | ||
@@ -18,0 +18,0 @@ }; |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,7 +8,7 @@ import * as monoid from "@fp-ts/core/Monoid"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare type Ordering = -1 | 0 | 1; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -18,3 +18,3 @@ export declare const reverse: (o: Ordering) => Ordering; | ||
* @category pattern matching | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -24,3 +24,3 @@ export declare const match: <A, B, C = B>(onLessThan: () => A, onEqual: () => B, onGreaterThan: () => C) => (o: Ordering) => A | B | C; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -30,9 +30,5 @@ export declare const Semigroup: semigroup.Semigroup<Ordering>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const Monoid: monoid.Monoid<Ordering>; | ||
/** | ||
* @since 3.0.0 | ||
*/ | ||
export declare const sign: (n: number) => Ordering; | ||
//# sourceMappingURL=Ordering.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.sign = exports.reverse = exports.match = exports.Semigroup = exports.Monoid = void 0; | ||
exports.reverse = exports.match = exports.Semigroup = exports.Monoid = void 0; | ||
@@ -16,15 +16,12 @@ var monoid = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Monoid")); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const reverse = o => o === -1 ? 1 : o === 1 ? -1 : 0; // ------------------------------------------------------------------------------------- | ||
// pattern matching | ||
// ------------------------------------------------------------------------------------- | ||
const reverse = o => o === -1 ? 1 : o === 1 ? -1 : 0; | ||
/** | ||
* @category pattern matching | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -38,3 +35,3 @@ | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -45,5 +42,5 @@ | ||
const Semigroup = { | ||
combine: (o1, o2) => o1 !== 0 ? o1 : o2, | ||
combineMany: (start, others) => { | ||
let ordering = start; | ||
combine: that => self => self !== 0 ? self : that, | ||
combineMany: collection => self => { | ||
let ordering = self; | ||
@@ -54,3 +51,3 @@ if (ordering !== 0) { | ||
for (ordering of others) { | ||
for (ordering of collection) { | ||
if (ordering !== 0) { | ||
@@ -66,3 +63,3 @@ return ordering; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -72,11 +69,3 @@ | ||
const Monoid = /*#__PURE__*/monoid.fromSemigroup(Semigroup, 0); | ||
/** | ||
* @since 3.0.0 | ||
*/ | ||
exports.Monoid = Monoid; | ||
const sign = n => n <= -1 ? -1 : n >= 1 ? 1 : 0; | ||
exports.sign = sign; | ||
//# sourceMappingURL=Ordering.js.map |
{ | ||
"name": "@fp-ts/core", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
import type { Sortable } from "@fp-ts/core/Sortable"; | ||
/** | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Semigroup<A> { | ||
readonly combine: (first: A, second: A) => A; | ||
readonly combineMany: (start: A, others: Iterable<A>) => A; | ||
readonly combine: (that: A) => (self: A) => A; | ||
readonly combineMany: (collection: Iterable<A>) => (self: A) => A; | ||
} | ||
/** | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const fromCombine: <A>(combine: (first: A, second: A) => A) => Semigroup<A>; | ||
export declare const fromCombine: <A>(combine: (that: A) => (self: A) => A) => Semigroup<A>; | ||
/** | ||
* Get a semigroup where `combine` will return the minimum, based on the provided order. | ||
* `Semigroup` that returns last minimum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const min: <A>(Sortable: Sortable<A>) => Semigroup<A>; | ||
/** | ||
* Get a semigroup where `combine` will return the maximum, based on the provided order. | ||
* `Semigroup` that returns last maximum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,3 +31,3 @@ export declare const max: <A>(Sortable: Sortable<A>) => Semigroup<A>; | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -38,3 +38,3 @@ export declare const constant: <A>(a: A) => Semigroup<A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -45,3 +45,3 @@ export declare const reverse: <A>(Semigroup: Semigroup<A>) => Semigroup<A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -52,7 +52,7 @@ export declare const struct: <A>(semigroups: { [K in keyof A]: Semigroup<A[K]>; }) => Semigroup<{ readonly [K_1 in keyof A]: A[K_1]; }>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const tuple: <A extends readonly unknown[]>(...semigroups: { [K in keyof A]: Semigroup<A[K]>; }) => Semigroup<Readonly<A>>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -64,3 +64,3 @@ export declare const intercalate: <A>(separator: A) => (Semigroup: Semigroup<A>) => Semigroup<A>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -72,5 +72,5 @@ export declare const first: <A = never>() => Semigroup<A>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const last: <A = never>() => Semigroup<A>; | ||
//# sourceMappingURL=Semigroup.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,11 +17,11 @@ | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const fromCombine = combine => ({ | ||
combine, | ||
combineMany: (start, others) => { | ||
let out = start; | ||
combineMany: collection => self => { | ||
let out = self; | ||
for (const a of others) { | ||
out = combine(out, a); | ||
for (const a of collection) { | ||
out = combine(a)(out); | ||
} | ||
@@ -33,6 +33,6 @@ | ||
/** | ||
* Get a semigroup where `combine` will return the minimum, based on the provided order. | ||
* `Semigroup` that returns last minimum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -43,8 +43,8 @@ | ||
const min = Sortable => fromCombine((first, second) => Sortable.compare(first, second) === -1 ? first : second); | ||
const min = Sortable => fromCombine(that => self => Sortable.compare(that)(self) === -1 ? self : that); | ||
/** | ||
* Get a semigroup where `combine` will return the maximum, based on the provided order. | ||
* `Semigroup` that returns last maximum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -55,6 +55,6 @@ | ||
const max = Sortable => fromCombine((first, second) => Sortable.compare(first, second) === 1 ? first : second); | ||
const max = Sortable => fromCombine(that => self => Sortable.compare(that)(self) === 1 ? self : that); | ||
/** | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -66,4 +66,4 @@ | ||
const constant = a => ({ | ||
combine: () => a, | ||
combineMany: () => a | ||
combine: () => () => a, | ||
combineMany: () => () => a | ||
}); | ||
@@ -73,3 +73,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -81,6 +81,6 @@ | ||
const reverse = Semigroup => ({ | ||
combine: (first, second) => Semigroup.combine(second, first), | ||
combineMany: (start, others) => { | ||
const reversed = Array.from(others).reverse(); | ||
return reversed.length === 0 ? start : Semigroup.combine(reversed.reduceRight((first, second) => Semigroup.combine(first, second)), start); | ||
combine: that => self => Semigroup.combine(that)(self), | ||
combineMany: collection => self => { | ||
const reversed = Array.from(collection).reverse(); | ||
return reversed.length === 0 ? self : Semigroup.combine(self)(reversed.reduceRight((first, second) => Semigroup.combine(second)(first))); | ||
} | ||
@@ -91,3 +91,3 @@ }); | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -98,3 +98,3 @@ | ||
const struct = semigroups => fromCombine((first, second) => { | ||
const struct = semigroups => fromCombine(that => self => { | ||
const r = {}; | ||
@@ -104,3 +104,3 @@ | ||
if (Object.prototype.hasOwnProperty.call(semigroups, k)) { | ||
r[k] = semigroups[k].combine(first[k], second[k]); | ||
r[k] = semigroups[k].combine(that[k])(self[k]); | ||
} | ||
@@ -114,3 +114,3 @@ } | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -121,5 +121,5 @@ | ||
const tuple = (...semigroups) => fromCombine((first, second) => semigroups.map((Semigroup, i) => Semigroup.combine(first[i], second[i]))); | ||
const tuple = (...semigroups) => fromCombine(that => self => semigroups.map((Semigroup, i) => Semigroup.combine(that[i])(self[i]))); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -130,3 +130,3 @@ | ||
const intercalate = separator => Semigroup => fromCombine((first, second) => Semigroup.combineMany(first, [separator, second])); | ||
const intercalate = separator => Semigroup => fromCombine(that => Semigroup.combineMany([separator, that])); | ||
/** | ||
@@ -136,3 +136,3 @@ * Always return the first argument. | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -144,4 +144,4 @@ | ||
const first = () => ({ | ||
combine: _Function.identity, | ||
combineMany: _Function.identity | ||
combine: () => _Function.identity, | ||
combineMany: () => _Function.identity | ||
}); | ||
@@ -152,3 +152,3 @@ /** | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -160,7 +160,7 @@ | ||
const last = () => ({ | ||
combine: (_, second) => second, | ||
combineMany: (start, others) => { | ||
let a = start; // eslint-disable-next-line no-empty | ||
combine: second => () => second, | ||
combineMany: collection => self => { | ||
let a = self; // eslint-disable-next-line no-empty | ||
for (a of others) {} | ||
for (a of collection) {} | ||
@@ -167,0 +167,0 @@ return a; |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Functor } from "@fp-ts/core/Functor"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,4 +17,4 @@ export interface Semigroupal<F extends TypeLambda> extends Functor<F> { | ||
*/ | ||
readonly zipWith: <S, R1, O1, E1, A, R2, O2, E2, B, C>(fa: Kind<F, S, R1, O1, E1, A>, fb: Kind<F, S, R2, O2, E2, B>, f: (a: A, b: B) => C) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C>; | ||
readonly zipMany: <S, R, O, E, A>(start: Kind<F, S, R, O, E, A>, others: Iterable<Kind<F, S, R, O, E, A>>) => Kind<F, S, R, O, E, [A, ...ReadonlyArray<A>]>; | ||
readonly zipWith: <S, R2, O2, E2, B, A, C>(that: Kind<F, S, R2, O2, E2, B>, f: (a: A, b: B) => C) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C>; | ||
readonly zipMany: <S, R, O, E, A>(collection: Iterable<Kind<F, S, R, O, E, A>>) => (self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, readonly [A, ...ReadonlyArray<A>]>; | ||
} | ||
@@ -24,17 +24,17 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const zipWithComposition: <F extends TypeLambda, G extends TypeLambda>(SemigroupalF: Semigroupal<F>, SemigroupalG: Semigroupal<G>) => <FS, FR1, FO1, FE1, GS, GR1, GO1, GE1, A, FR2, FO2, FE2, GR2, GO2, GE2, B, C>(fga: Kind<F, FS, FR1, FO1, FE1, Kind<G, GS, GR1, GO1, GE1, A>>, fgb: Kind<F, FS, FR2, FO2, FE2, Kind<G, GS, GR2, GO2, GE2, B>>, f: (a: A, b: B) => C) => Kind<F, FS, FR1 & FR2, FO1 | FO2, FE1 | FE2, Kind<G, GS, GR1 & GR2, GO1 | GO2, GE1 | GE2, C>>; | ||
export declare const zipWithComposition: <F extends TypeLambda, G extends TypeLambda>(SemigroupalF: Semigroupal<F>, SemigroupalG: Semigroupal<G>) => <FS, FR2, FO2, FE2, GS, GR2, GO2, GE2, B, A, C>(that: Kind<F, FS, FR2, FO2, FE2, Kind<G, GS, GR2, GO2, GE2, B>>, f: (a: A, b: B) => C) => <FR1, FO1, FE1, GR1, GO1, GE1>(self: Kind<F, FS, FR1, FO1, FE1, Kind<G, GS, GR1, GO1, GE1, A>>) => Kind<F, FS, FR1 & FR2, FO2 | FO1, FE2 | FE1, Kind<G, GS, GR1 & GR2, GO2 | GO1, GE2 | GE1, C>>; | ||
/** | ||
* Returns a default `zipMany` composition. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const zipManyComposition: <F extends TypeLambda, G extends TypeLambda>(SemigroupalF: Semigroupal<F>, SemigroupalG: Semigroupal<G>) => <FS, FR, FO, FE, GS, GR, GO, GE, A>(start: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>, others: Iterable<Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>>) => Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, [A, ...A[]]>>; | ||
export declare const zipManyComposition: <F extends TypeLambda, G extends TypeLambda>(SemigroupalF: Semigroupal<F>, SemigroupalG: Semigroupal<G>) => <FS, FR, FO, FE, GS, GR, GO, GE, A>(collection: Iterable<Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>>) => (self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, readonly [A, ...A[]]>>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const ap: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2, A>(fa: Kind<F, S, R2, O2, E2, A>) => <R1, O1, E1, B>(self: Kind<F, S, R1, O1, E1, (a: A) => B>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, B>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -46,3 +46,3 @@ export declare const zip: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2, B, A>(that: Kind<F, S, R2, O2, E2, B>) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, readonly [A, B]>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -55,3 +55,3 @@ export declare const zipWith: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2, B, A, C>(that: Kind<F, S, R2, O2, E2, B>, f: (a: A, b: B) => C) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, C>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -64,3 +64,3 @@ export declare const zipLeftPar: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2>(that: Kind<F, S, R2, O2, E2, unknown>) => <R1, O1, E1, A>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -71,3 +71,3 @@ export declare const zipRightPar: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2, A>(that: Kind<F, S, R2, O2, E2, A>) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, unknown>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, A>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -78,3 +78,3 @@ export declare const bindRight: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <N extends string, A extends object, S, R2, O2, E2, B>(name: Exclude<N, keyof A>, fb: Kind<F, S, R2, O2, E2, B>) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -85,3 +85,3 @@ export declare const zipFlatten: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <S, R2, O2, E2, B>(that: Kind<F, S, R2, O2, E2, B>) => <R1, O1, E1, A extends readonly unknown[]>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O2 | O1, E2 | E1, readonly [...A, B]>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -92,3 +92,3 @@ export declare const liftSemigroup: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <A, S, R, O, E>(Semigroup: Semigroup<A>) => Semigroup<Kind<F, S, R, O, E, A>>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -99,5 +99,5 @@ export declare const lift2: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <A, B, C>(f: (a: A, b: B) => C) => <S, R1, O1, E1, R2, O2, E2>(fa: Kind<F, S, R1, O1, E1, A>, fb: Kind<F, S, R2, O2, E2, B>) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const lift3: <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => <A, B, C, D>(f: (a: A, b: B, c: C) => D) => <S, R1, O1, E1, R2, O2, E2, R3, O3, E3>(fa: Kind<F, S, R1, O1, E1, A>, fb: Kind<F, S, R2, O2, E2, B>, fc: Kind<F, S, R3, O3, E3, C>) => Kind<F, S, R1 & R2 & R3, O1 | O2 | O3, E1 | E2 | E3, D>; | ||
//# sourceMappingURL=Semigroupal.d.ts.map |
@@ -19,9 +19,9 @@ "use strict"; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const zipWithComposition = (SemigroupalF, SemigroupalG) => (fga, fgb, f) => (0, _Function.pipe)(SemigroupalF.zipWith(fga, fgb, (ga, gb) => SemigroupalG.zipWith(ga, gb, f))); | ||
const zipWithComposition = (SemigroupalF, SemigroupalG) => (that, f) => self => (0, _Function.pipe)(self, SemigroupalF.zipWith(that, (ga, gb) => (0, _Function.pipe)(ga, SemigroupalG.zipWith(gb, f)))); | ||
/** | ||
* Returns a default `zipMany` composition. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -32,5 +32,5 @@ | ||
const zipManyComposition = (SemigroupalF, SemigroupalG) => (start, others) => (0, _Function.pipe)(SemigroupalF.zipMany(start, others), SemigroupalF.map(([ga, ...gas]) => SemigroupalG.zipMany(ga, gas))); | ||
const zipManyComposition = (SemigroupalF, SemigroupalG) => collection => self => (0, _Function.pipe)(self, SemigroupalF.zipMany(collection), SemigroupalF.map(([ga, ...gas]) => SemigroupalG.zipMany(gas)(ga))); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -41,5 +41,5 @@ | ||
const ap = Semigroupal => fa => fab => Semigroupal.zipWith(fa, fab, (a, f) => f(a)); | ||
const ap = Semigroupal => fa => self => (0, _Function.pipe)(self, Semigroupal.zipWith(fa, (f, a) => f(a))); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -50,3 +50,3 @@ | ||
const zip = Semigroupal => that => self => Semigroupal.zipWith(self, that, (a, b) => [a, b]); | ||
const zip = Semigroupal => that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, (a, b) => [a, b])); | ||
/** | ||
@@ -56,3 +56,3 @@ * Zips this effect with the specified effect using the | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -63,3 +63,3 @@ | ||
const zipWith = Semigroupal => (that, f) => self => Semigroupal.zipWith(self, that, f); | ||
const zipWith = Semigroupal => (that, f) => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, f)); | ||
/** | ||
@@ -70,3 +70,3 @@ * Returns an effect that executes both this effect and the specified effect, | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -77,3 +77,3 @@ | ||
const zipLeftPar = Semigroupal => that => self => Semigroupal.zipWith(self, that, _Function.identity); | ||
const zipLeftPar = Semigroupal => that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, _Function.identity)); | ||
/** | ||
@@ -84,3 +84,3 @@ * Returns an effect that executes both this effect and the specified effect, | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -91,7 +91,7 @@ | ||
const zipRightPar = Semigroupal => that => self => Semigroupal.zipWith(self, that, (_, a) => a); | ||
const zipRightPar = Semigroupal => that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, (_, a) => a)); | ||
/** | ||
* A variant of `FlatMap.bind` that sequentially ignores the scope. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -102,9 +102,9 @@ | ||
const bindRight = Semigroupal => (name, fb) => self => Semigroupal.zipWith(self, fb, (a, b) => Object.assign({}, a, { | ||
const bindRight = Semigroupal => (name, fb) => self => (0, _Function.pipe)(self, Semigroupal.zipWith(fb, (a, b) => Object.assign({}, a, { | ||
[name]: b | ||
})); | ||
}))); | ||
/** | ||
* Zips this effect with the specified effect. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -115,7 +115,7 @@ | ||
const zipFlatten = Semigroupal => that => self => Semigroupal.zipWith(self, that, (a, b) => [...a, b]); | ||
const zipFlatten = Semigroupal => that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, (a, b) => [...a, b])); | ||
/** | ||
* Lift a semigroup into 'F', the inner values are combined using the provided `Semigroup`. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -126,7 +126,7 @@ | ||
const liftSemigroup = Semigroupal => Semigroup => semigroup.fromCombine((first, second) => Semigroupal.zipWith(first, second, Semigroup.combine)); | ||
const liftSemigroup = Semigroupal => Semigroup => semigroup.fromCombine(that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, (a1, a2) => Semigroup.combine(a2)(a1)))); | ||
/** | ||
* Lifts a binary function into `F`. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -137,5 +137,5 @@ | ||
const lift2 = Semigroupal => f => (fa, fb) => Semigroupal.zipWith(fa, fb, f); | ||
const lift2 = Semigroupal => f => (fa, fb) => (0, _Function.pipe)(fa, Semigroupal.zipWith(fb, f)); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -146,7 +146,7 @@ | ||
const zip3With = Semigroupal => (fa, fb, fc, f) => (0, _Function.pipe)(Semigroupal.zipMany(fa, [fb, fc]), Semigroupal.map(([a, b, c]) => f(a, b, c))); | ||
const zip3With = Semigroupal => (fa, fb, fc, f) => (0, _Function.pipe)(fa, Semigroupal.zipMany([fb, fc]), Semigroupal.map(([a, b, c]) => f(a, b, c))); | ||
/** | ||
* Lifts a ternary function into 'F'. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -153,0 +153,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,8 +8,8 @@ import type { Functor } from "@fp-ts/core/Functor"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface SemigroupKind<F extends TypeLambda> extends Functor<F> { | ||
readonly combineKind: <S, R, O, E, A, B>(first: Kind<F, S, R, O, E, A>, second: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, A | B>; | ||
readonly combineKindMany: <S, R, O, E, A>(start: Kind<F, S, R, O, E, A>, others: Iterable<Kind<F, S, R, O, E, A>>) => Kind<F, S, R, O, E, A>; | ||
readonly combineKind: <S, R2, O2, E2, B>(that: Kind<F, S, R2, O2, E2, B>) => <R1, O1, E1, A>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A | B>; | ||
readonly combineKindMany: <S, R, O, E, A>(collection: Iterable<Kind<F, S, R, O, E, A>>) => (self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, A>; | ||
} | ||
//# sourceMappingURL=SemigroupKind.d.ts.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,10 +11,10 @@ import type * as contravariant from "@fp-ts/core/Contravariant"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Sortable<A> { | ||
readonly compare: (first: A, second: A) => Ordering; | ||
readonly compare: (that: A) => (self: A) => Ordering; | ||
} | ||
/** | ||
* @category type lambdas | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,17 +26,17 @@ export interface SortableTypeLambda extends TypeLambda { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const fromCompare: <A>(compare: (first: A, second: A) => Ordering) => Sortable<A>; | ||
export declare const fromCompare: <A>(compare: (that: A) => (self: A) => Ordering) => Sortable<A>; | ||
/** | ||
* Given a tuple of `Compare`s returns a `Compare` for the tuple. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const tuple: <A extends readonly unknown[]>(...compares: { [K in keyof A]: Sortable<A[K]>; }) => Sortable<Readonly<A>>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const reverse: <A>(Sortable: Sortable<A>) => Sortable<A>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -46,3 +46,3 @@ export declare const contramap: <B, A>(f: (b: B) => A) => (self: Sortable<A>) => Sortable<B>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -52,3 +52,3 @@ export declare const getSemigroup: <A>() => Semigroup<Sortable<A>>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -58,3 +58,3 @@ export declare const getMonoid: <A>() => Monoid<Sortable<A>>; | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -65,39 +65,39 @@ export declare const Contravariant: contravariant.Contravariant<SortableTypeLambda>; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const lt: <A>(Sortable: Sortable<A>) => (first: A, second: A) => boolean; | ||
export declare const lt: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => boolean; | ||
/** | ||
* Test whether one value is _strictly greater than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const gt: <A>(Sortable: Sortable<A>) => (first: A, second: A) => boolean; | ||
export declare const gt: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => boolean; | ||
/** | ||
* Test whether one value is _non-strictly less than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const leq: <A>(Sortable: Sortable<A>) => (first: A, second: A) => boolean; | ||
export declare const leq: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => boolean; | ||
/** | ||
* Test whether one value is _non-strictly greater than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const geq: <A>(Sortable: Sortable<A>) => (first: A, second: A) => boolean; | ||
export declare const geq: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => boolean; | ||
/** | ||
* Take the minimum of two values. If they are considered equal, the first argument is chosen. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const min: <A>(Sortable: Sortable<A>) => (first: A, second: A) => A; | ||
export declare const min: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => A; | ||
/** | ||
* Take the maximum of two values. If they are considered equal, the first argument is chosen. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const max: <A>(Sortable: Sortable<A>) => (first: A, second: A) => A; | ||
export declare const max: <A>(Sortable: Sortable<A>) => (that: A) => (self: A) => A; | ||
/** | ||
* Clamp a value between a minimum and a maximum. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -108,5 +108,5 @@ export declare const clamp: <A>(Sortable: Sortable<A>) => (minimum: A, maximum: A) => (a: A) => A; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const between: <A>(Sortable: Sortable<A>) => (minimum: A, maximum: A) => (a: A) => boolean; | ||
//# sourceMappingURL=Sortable.d.ts.map |
@@ -16,6 +16,6 @@ "use strict"; | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const fromCompare = compare => ({ | ||
compare: (first, second) => first === second ? 0 : compare(first, second) | ||
compare: that => self => self === that ? 0 : compare(that)(self) | ||
}); | ||
@@ -25,3 +25,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -32,7 +32,7 @@ | ||
const tuple = (...compares) => fromCompare((first, second) => { | ||
const tuple = (...compares) => fromCompare(that => self => { | ||
let i = 0; | ||
for (; i < compares.length - 1; i++) { | ||
const r = compares[i].compare(first[i], second[i]); | ||
const r = compares[i].compare(that[i])(self[i]); | ||
@@ -44,6 +44,6 @@ if (r !== 0) { | ||
return compares[i].compare(first[i], second[i]); | ||
return compares[i].compare(that[i])(self[i]); | ||
}); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -54,5 +54,5 @@ | ||
const reverse = Sortable => fromCompare((first, second) => Sortable.compare(second, first)); | ||
const reverse = Sortable => fromCompare(that => self => Sortable.compare(self)(that)); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -63,6 +63,6 @@ | ||
const contramap = f => self => fromCompare((first, second) => self.compare(f(first), f(second))); | ||
const contramap = f => self => fromCompare(b2 => b1 => self.compare(f(b2))(f(b1))); | ||
/** | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -74,4 +74,4 @@ | ||
const getSemigroup = () => ({ | ||
combine: (s1, s2) => fromCompare((first, second) => { | ||
const out = s1.compare(first, second); | ||
combine: sortable2 => sortable1 => fromCompare(that => self => { | ||
const out = sortable1.compare(that)(self); | ||
@@ -82,6 +82,6 @@ if (out !== 0) { | ||
return s2.compare(first, second); | ||
return sortable2.compare(that)(self); | ||
}), | ||
combineMany: (start, others) => fromCompare((first, second) => { | ||
let out = start.compare(first, second); | ||
combineMany: collection => self => fromCompare(a2 => a1 => { | ||
let out = self.compare(a2)(a1); | ||
@@ -92,4 +92,4 @@ if (out !== 0) { | ||
for (const sortable of others) { | ||
out = sortable.compare(first, second); | ||
for (const sortable of collection) { | ||
out = sortable.compare(a2)(a1); | ||
@@ -106,3 +106,3 @@ if (out !== 0) { | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -113,6 +113,6 @@ | ||
const getMonoid = () => monoid.fromSemigroup(getSemigroup(), fromCompare(() => 0)); | ||
const getMonoid = () => monoid.fromSemigroup(getSemigroup(), fromCompare(() => () => 0)); | ||
/** | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -128,3 +128,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -134,7 +134,7 @@ | ||
const lt = Sortable => (first, second) => Sortable.compare(first, second) === -1; | ||
const lt = Sortable => that => self => Sortable.compare(that)(self) === -1; | ||
/** | ||
* Test whether one value is _strictly greater than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -145,7 +145,7 @@ | ||
const gt = Sortable => (first, second) => Sortable.compare(first, second) === 1; | ||
const gt = Sortable => that => self => Sortable.compare(that)(self) === 1; | ||
/** | ||
* Test whether one value is _non-strictly less than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -156,7 +156,7 @@ | ||
const leq = Sortable => (first, second) => Sortable.compare(first, second) !== 1; | ||
const leq = Sortable => that => self => Sortable.compare(that)(self) !== 1; | ||
/** | ||
* Test whether one value is _non-strictly greater than_ another. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -167,7 +167,7 @@ | ||
const geq = Sortable => (first, second) => Sortable.compare(first, second) !== -1; | ||
const geq = Sortable => that => self => Sortable.compare(that)(self) !== -1; | ||
/** | ||
* Take the minimum of two values. If they are considered equal, the first argument is chosen. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -178,7 +178,7 @@ | ||
const min = Sortable => (first, second) => first === second || Sortable.compare(first, second) < 1 ? first : second; | ||
const min = Sortable => that => self => self === that || Sortable.compare(that)(self) < 1 ? self : that; | ||
/** | ||
* Take the maximum of two values. If they are considered equal, the first argument is chosen. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -189,7 +189,7 @@ | ||
const max = Sortable => (first, second) => first === second || Sortable.compare(first, second) > -1 ? first : second; | ||
const max = Sortable => that => self => self === that || Sortable.compare(that)(self) > -1 ? self : that; | ||
/** | ||
* Clamp a value between a minimum and a maximum. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -200,11 +200,7 @@ | ||
const clamp = Sortable => { | ||
const min_ = min(Sortable); | ||
const max_ = max(Sortable); | ||
return (minimum, maximum) => a => min_(maximum, max_(minimum, a)); | ||
}; | ||
const clamp = Sortable => (minimum, maximum) => a => min(Sortable)(max(Sortable)(a)(minimum))(maximum); | ||
/** | ||
* Test whether a value is between a minimum and a maximum (inclusive). | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -215,9 +211,5 @@ | ||
const between = Sortable => { | ||
const lt_ = lt(Sortable); | ||
const gt_ = gt(Sortable); | ||
return (minimum, maximum) => a => !lt_(a, minimum) && !gt_(a, maximum); | ||
}; | ||
const between = Sortable => (minimum, maximum) => a => !lt(Sortable)(minimum)(a) && !gt(Sortable)(maximum)(a); | ||
exports.between = between; | ||
//# sourceMappingURL=Sortable.js.map |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ import type { Functor } from "@fp-ts/core/Functor" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -21,3 +21,3 @@ export interface Bifunctor<F extends TypeLambda> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -35,7 +35,7 @@ export const mapLeft = <F extends TypeLambda>( | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const map = <F extends TypeLambda>(Bifunctor: Bifunctor<F>): Functor<F>["map"] => | ||
<A, B>(f: (a: A) => B): (<S, R, O, E>(self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, B>) => | ||
Bifunctor.mapBoth(e => e, f) | ||
Bifunctor.mapBoth(identity, f) | ||
@@ -45,3 +45,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -48,0 +48,0 @@ export const mapBothComposition = <F extends TypeLambda, G extends TypeLambda>( |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import * as compare from "@fp-ts/core/Sortable" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -19,3 +19,3 @@ export interface Bounded<A> extends Sortable<A> { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,3 +31,3 @@ export const fromSortable = <A>(Sortable: Sortable<A>, maximum: A, minimum: A): Bounded<A> => ({ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -39,3 +39,3 @@ export const clamp = <A>(B: Bounded<A>): (a: A) => A => compare.clamp(B)(B.minimum, B.maximum) | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -42,0 +42,0 @@ export const reverse = <A>(Bounded: Bounded<A>): Bounded<A> => |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Composable } from "@fp-ts/core/Composable" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -12,0 +12,0 @@ export interface Category<F extends TypeLambda> extends Composable<F> { |
/** | ||
* Kleisli categories. | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,3 +11,3 @@ import type { ComposableKind } from "@fp-ts/core/ComposableKind" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -14,0 +14,0 @@ export interface CategoryKind<F extends TypeLambda> extends ComposableKind<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Extendable } from "@fp-ts/core/Extendable" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -12,0 +12,0 @@ export interface Comonad<F extends TypeLambda> extends Extendable<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Composable<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface ComposableKind<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Contravariant<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Functor } from "@fp-ts/core/Functor" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -12,0 +12,0 @@ export interface Extendable<F extends TypeLambda> extends Functor<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,3 +11,3 @@ import type { ComposableKind } from "@fp-ts/core/ComposableKind" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -25,14 +25,10 @@ export interface FlatMap<M extends TypeLambda> extends Functor<M> { | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const zipLeft = <F extends TypeLambda>(FlatMap: FlatMap<F>) => { | ||
const tap_ = tap(FlatMap) | ||
return <S, R2, O2, E2>( | ||
export const zipLeft = <F extends TypeLambda>(FlatMap: FlatMap<F>) => | ||
<S, R2, O2, E2>( | ||
that: Kind<F, S, R2, O2, E2, unknown> | ||
): (<R1, O1, E1, A>( | ||
self: Kind<F, S, R1, O1, E1, A> | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A>) => { | ||
return tap_(() => that) | ||
} | ||
} | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A>) => tap(FlatMap)(() => that) | ||
@@ -43,17 +39,14 @@ /** | ||
* @category sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const zipRight = <F extends TypeLambda>(FlatMap: FlatMap<F>) => { | ||
return <S, R2, O2, E2, A>( | ||
export const zipRight = <F extends TypeLambda>(FlatMap: FlatMap<F>) => | ||
<S, R2, O2, E2, A>( | ||
that: Kind<F, S, R2, O2, E2, A> | ||
): (<R1, O1, E1>( | ||
self: Kind<F, S, R1, O1, E1, unknown> | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A>) => { | ||
return FlatMap.flatMap(() => that) | ||
} | ||
} | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A>) => FlatMap.flatMap(() => that) | ||
/** | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -82,3 +75,3 @@ export const bind = <M extends TypeLambda>(FlatMap: FlatMap<M>) => | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -92,3 +85,3 @@ export const composeKind = <F extends TypeLambda>( | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -95,0 +88,0 @@ export const tap = <F extends TypeLambda>(FlatMap: FlatMap<F>) => |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,7 +26,20 @@ export interface Foldable<F extends TypeLambda> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const toReadonlyArrayWith = <F extends TypeLambda>( | ||
Foldable: Foldable<F> | ||
) => | ||
<S, R, O, E, A, B>(self: Kind<F, S, R, O, E, A>, f: (a: A) => B): ReadonlyArray<B> => | ||
Foldable.reduce<A, Array<B>>([], (out, a) => { | ||
out.push(f(a)) | ||
return out | ||
})(self) | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export const foldMap = <F extends TypeLambda>(Foldable: Foldable<F>) => | ||
<M>(Monoid: Monoid<M>) => | ||
<A>(f: (a: A) => M): <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => M => | ||
Foldable.reduce(Monoid.empty, (m, a) => Monoid.combine(m, f(a))) | ||
<A>(f: (a: A) => M) => | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): M => | ||
Monoid.combineAll(toReadonlyArrayWith(Foldable)(self, f)) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,4 +26,16 @@ export interface FoldableWithIndex<F extends TypeLambda, I> extends TypeClass<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const toReadonlyArrayWith = <F extends TypeLambda, I>( | ||
FoldableWithIndex: FoldableWithIndex<F, I> | ||
) => | ||
<S, R, O, E, A, B>(self: Kind<F, S, R, O, E, A>, f: (a: A, i: I) => B): ReadonlyArray<B> => | ||
FoldableWithIndex.reduceWithIndex<A, Array<B>>([], (out, a, i) => { | ||
out.push(f(a, i)) | ||
return out | ||
})(self) | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export const foldMapWithIndex = <F extends TypeLambda, I>( | ||
@@ -33,3 +45,4 @@ FoldableWithIndex: FoldableWithIndex<F, I> | ||
<M>(Monoid: Monoid<M>) => | ||
<A>(f: (a: A, i: I) => M): <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => M => | ||
FoldableWithIndex.reduceWithIndex(Monoid.empty, (m, a, i) => Monoid.combine(m, f(a, i))) | ||
<A>(f: (a: A, i: I) => M) => | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): M => | ||
Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(self, f)) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,3 +20,3 @@ export interface Functor<F extends TypeLambda> extends TypeClass<F> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -34,3 +34,3 @@ export const mapComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -43,3 +43,3 @@ export const flap = <F extends TypeLambda>(Functor: Functor<F>) => | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -52,3 +52,3 @@ export const as = <F extends TypeLambda>(Functor: Functor<F>) => | ||
* @category mapping | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -66,3 +66,3 @@ export const unit = <F extends TypeLambda>( | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -83,5 +83,4 @@ export const bindTo = <F extends TypeLambda>(Functor: Functor<F>) => | ||
self: Kind<F, S, R, O, E, A> | ||
) => Kind<F, S, R, O, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>) => { | ||
return (name, f) => F.map((a) => Object.assign({}, a, { [name]: f(a) }) as any) | ||
} | ||
) => Kind<F, S, R, O, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>) => | ||
(name, f) => F.map((a) => Object.assign({}, a, { [name]: f(a) }) as any) | ||
@@ -91,3 +90,3 @@ export { | ||
* @category do notation | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -103,3 +102,3 @@ let_ as let | ||
* @category tuple sequencing | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -106,0 +105,0 @@ export const tupled = <F extends TypeLambda>( |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,3 +11,3 @@ export declare const URI: unique symbol | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -19,3 +19,3 @@ export interface TypeClass<F extends TypeLambda> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,3 +31,3 @@ export interface TypeLambda { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -34,0 +34,0 @@ export type Kind<F extends TypeLambda, InOut1, In1, Out3, Out2, Out1> = F extends { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -25,8 +25,7 @@ | ||
import * as ordering from "@fp-ts/core/Ordering" | ||
import * as pointed from "@fp-ts/core/Pointed" | ||
import * as semigroup from "@fp-ts/core/Semigroup" | ||
import * as semigroupal from "@fp-ts/core/Semigroupal" | ||
import * as semigroupKind from "@fp-ts/core/SemigroupKind" | ||
import * as show from "@fp-ts/core/Show" | ||
import * as sortable from "@fp-ts/core/Sortable" | ||
import * as succeed from "@fp-ts/core/Succeed" | ||
import * as traversable from "@fp-ts/core/Traversable" | ||
@@ -38,3 +37,3 @@ import * as traversableWithIndex from "@fp-ts/core/TraversableWithIndex" | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -44,3 +43,3 @@ bifunctor, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -50,3 +49,3 @@ bounded, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -56,3 +55,3 @@ category, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -62,3 +61,3 @@ categoryKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -68,3 +67,3 @@ comonad, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -74,3 +73,3 @@ composable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -80,3 +79,3 @@ composableKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -86,3 +85,3 @@ contravariant, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -92,3 +91,3 @@ extendable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -98,3 +97,3 @@ flatMap, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -104,3 +103,3 @@ foldable, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -110,7 +109,7 @@ foldableWithIndex, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
functor, | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -120,3 +119,3 @@ hkt, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -126,3 +125,3 @@ invariant, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -132,3 +131,3 @@ monad, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -138,3 +137,3 @@ monoid, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -144,3 +143,3 @@ monoidal, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -150,3 +149,3 @@ monoidKind, | ||
* @category data types | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -156,8 +155,13 @@ ordering, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
pointed, | ||
/** | ||
* @category type classes | ||
* @since 1.0.0 | ||
*/ | ||
semigroup, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -167,3 +171,3 @@ semigroupal, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -173,25 +177,15 @@ semigroupKind, | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
show, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
*/ | ||
sortable, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
succeed, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
*/ | ||
traversable, | ||
/** | ||
* @category type classes | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
traversableWithIndex | ||
} |
/** | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -15,3 +15,3 @@ export const identity = <A>(a: A): A => a | ||
* @internal | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -18,0 +18,0 @@ export function pipe<A>(a: A): A |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -11,0 +11,0 @@ export interface Invariant<F extends TypeLambda> extends TypeClass<F> { |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
import type { FlatMap } from "@fp-ts/core/FlatMap" | ||
import type { TypeLambda } from "@fp-ts/core/HKT" | ||
import type { Succeed } from "@fp-ts/core/Succeed" | ||
import type { Pointed } from "@fp-ts/core/Pointed" | ||
/** | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Monad<F extends TypeLambda> extends Succeed<F>, FlatMap<F> {} | ||
export interface Monad<F extends TypeLambda> extends Pointed<F>, FlatMap<F> {} |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ import type { Bounded } from "@fp-ts/core/Bounded" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,3 +20,3 @@ export interface Monoid<A> extends Semigroup<A> { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,3 +26,3 @@ export const fromSemigroup = <A>(Semigroup: Semigroup<A>, empty: A): Monoid<A> => ({ | ||
empty, | ||
combineAll: (collection) => Semigroup.combineMany(empty, collection) | ||
combineAll: (collection) => Semigroup.combineMany(collection)(empty) | ||
}) | ||
@@ -36,3 +36,3 @@ | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -48,3 +48,3 @@ export const min = <A>(Bounded: Bounded<A>): Monoid<A> => | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -57,3 +57,3 @@ export const max = <A>(Bounded: Bounded<A>): Monoid<A> => | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -66,3 +66,3 @@ export const reverse = <A>(Monoid: Monoid<A>): Monoid<A> => | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -84,3 +84,3 @@ export const struct = <A>( | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -87,0 +87,0 @@ export const tuple = <A extends ReadonlyArray<unknown>>( |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -7,12 +7,11 @@ import type { Kind, TypeLambda } from "@fp-ts/core/HKT" | ||
import * as monoid from "@fp-ts/core/Monoid" | ||
import type { Pointed } from "@fp-ts/core/Pointed" | ||
import type { Semigroupal } from "@fp-ts/core/Semigroupal" | ||
import * as semigroupal from "@fp-ts/core/Semigroupal" | ||
import type { Succeed } from "@fp-ts/core/Succeed" | ||
/** | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Monoidal<F extends TypeLambda> extends Semigroupal<F>, Succeed<F> { | ||
/** sequence */ | ||
export interface Monoidal<F extends TypeLambda> extends Semigroupal<F>, Pointed<F> { | ||
readonly zipAll: <S, R, O, E, A>( | ||
@@ -26,3 +25,3 @@ collection: Iterable<Kind<F, S, R, O, E, A>> | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -33,3 +32,3 @@ export const liftMonoid = <F extends TypeLambda>(Monoidal: Monoidal<F>) => | ||
semigroupal.liftSemigroup(Monoidal)<A, S, R, O, E>(Monoid), | ||
Monoidal.succeed(Monoid.empty) | ||
Monoidal.of(Monoid.empty) | ||
) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Kind, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -24,3 +24,3 @@ export interface MonoidKind<F extends TypeLambda> extends SemigroupKind<F> { | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -36,4 +36,4 @@ export const fromSemigroupKind = <F extends TypeLambda>( | ||
collection: Iterable<Kind<F, S, R, O, E, A>> | ||
) => SemigroupKind.combineKindMany(emptyKind<S>(), collection) | ||
) => SemigroupKind.combineKindMany(collection)(emptyKind<S>()) | ||
} | ||
} |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import * as monoid from "@fp-ts/core/Monoid" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -15,13 +15,9 @@ export type Ordering = -1 | 0 | 1 | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const reverse = (o: Ordering): Ordering => (o === -1 ? 1 : o === 1 ? -1 : 0) | ||
// ------------------------------------------------------------------------------------- | ||
// pattern matching | ||
// ------------------------------------------------------------------------------------- | ||
/** | ||
* @category pattern matching | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -36,18 +32,19 @@ export const match = <A, B, C = B>( | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const Semigroup: semigroup.Semigroup<Ordering> = { | ||
combine: (o1, o2) => o1 !== 0 ? o1 : o2, | ||
combineMany: (start, others) => { | ||
let ordering = start | ||
if (ordering !== 0) { | ||
return ordering | ||
} | ||
for (ordering of others) { | ||
combine: (that) => (self) => self !== 0 ? self : that, | ||
combineMany: (collection) => | ||
(self) => { | ||
let ordering = self | ||
if (ordering !== 0) { | ||
return ordering | ||
} | ||
for (ordering of collection) { | ||
if (ordering !== 0) { | ||
return ordering | ||
} | ||
} | ||
return ordering | ||
} | ||
return ordering | ||
} | ||
} | ||
@@ -57,9 +54,4 @@ | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const Monoid: monoid.Monoid<Ordering> = monoid.fromSemigroup(Semigroup, 0) | ||
/** | ||
* @since 3.0.0 | ||
*/ | ||
export const sign = (n: number): Ordering => (n <= -1 ? -1 : n >= 1 ? 1 : 0) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,7 +9,7 @@ import { identity } from "@fp-ts/core/internal/Function" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Semigroup<A> { | ||
readonly combine: (first: A, second: A) => A | ||
readonly combineMany: (start: A, others: Iterable<A>) => A | ||
readonly combine: (that: A) => (self: A) => A | ||
readonly combineMany: (collection: Iterable<A>) => (self: A) => A | ||
} | ||
@@ -19,40 +19,41 @@ | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const fromCombine = <A>(combine: Semigroup<A>["combine"]): Semigroup<A> => ({ | ||
combine, | ||
combineMany: (start, others) => { | ||
let out: A = start | ||
for (const a of others) { | ||
out = combine(out, a) | ||
combineMany: (collection) => | ||
(self) => { | ||
let out: A = self | ||
for (const a of collection) { | ||
out = combine(a)(out) | ||
} | ||
return out | ||
} | ||
return out | ||
} | ||
}) | ||
/** | ||
* Get a semigroup where `combine` will return the minimum, based on the provided order. | ||
* `Semigroup` that returns last minimum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const min = <A>(Sortable: Sortable<A>): Semigroup<A> => | ||
fromCombine((first, second) => Sortable.compare(first, second) === -1 ? first : second) | ||
fromCombine((that) => (self) => Sortable.compare(that)(self) === -1 ? self : that) | ||
/** | ||
* Get a semigroup where `combine` will return the maximum, based on the provided order. | ||
* `Semigroup` that returns last maximum of elements. | ||
* | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const max = <A>(Sortable: Sortable<A>): Semigroup<A> => | ||
fromCombine((first, second) => Sortable.compare(first, second) === 1 ? first : second) | ||
fromCombine((that) => (self) => Sortable.compare(that)(self) === 1 ? self : that) | ||
/** | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const constant = <A>(a: A): Semigroup<A> => ({ | ||
combine: () => a, | ||
combineMany: () => a | ||
combine: () => () => a, | ||
combineMany: () => () => a | ||
}) | ||
@@ -63,15 +64,15 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const reverse = <A>(Semigroup: Semigroup<A>): Semigroup<A> => ({ | ||
combine: (first, second) => Semigroup.combine(second, first), | ||
combineMany: (start, others) => { | ||
const reversed = Array.from(others).reverse() | ||
return reversed.length === 0 ? | ||
start : | ||
Semigroup.combine( | ||
reversed.reduceRight((first, second) => Semigroup.combine(first, second)), | ||
start | ||
) | ||
} | ||
combine: (that) => (self) => Semigroup.combine(that)(self), | ||
combineMany: (collection) => | ||
(self) => { | ||
const reversed = Array.from(collection).reverse() | ||
return reversed.length === 0 ? | ||
self : | ||
Semigroup.combine(self)( | ||
reversed.reduceRight((first, second) => Semigroup.combine(second)(first)) | ||
) | ||
} | ||
}) | ||
@@ -82,3 +83,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -90,11 +91,13 @@ export const struct = <A>(semigroups: { [K in keyof A]: Semigroup<A[K]> }): Semigroup< | ||
> => | ||
fromCombine((first, second) => { | ||
const r = {} as any | ||
for (const k in semigroups) { | ||
if (Object.prototype.hasOwnProperty.call(semigroups, k)) { | ||
r[k] = semigroups[k].combine(first[k], second[k]) | ||
fromCombine((that) => | ||
(self) => { | ||
const r = {} as any | ||
for (const k in semigroups) { | ||
if (Object.prototype.hasOwnProperty.call(semigroups, k)) { | ||
r[k] = semigroups[k].combine(that[k])(self[k]) | ||
} | ||
} | ||
return r | ||
} | ||
return r | ||
}) | ||
) | ||
@@ -104,3 +107,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -110,8 +113,8 @@ export const tuple = <A extends ReadonlyArray<unknown>>( | ||
): Semigroup<Readonly<A>> => | ||
fromCombine((first, second) => | ||
semigroups.map((Semigroup, i) => Semigroup.combine(first[i], second[i])) as any | ||
fromCombine((that) => | ||
(self) => semigroups.map((Semigroup, i) => Semigroup.combine(that[i])(self[i])) as any | ||
) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -121,3 +124,3 @@ export const intercalate = <A>(separator: A) => | ||
fromCombine( | ||
(first, second) => Semigroup.combineMany(first, [separator, second]) | ||
(that) => Semigroup.combineMany([separator, that]) | ||
) | ||
@@ -129,7 +132,7 @@ | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const first = <A = never>(): Semigroup<A> => ({ | ||
combine: identity, | ||
combineMany: identity | ||
combine: () => identity, | ||
combineMany: () => identity | ||
}) | ||
@@ -141,12 +144,13 @@ | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const last = <A = never>(): Semigroup<A> => ({ | ||
combine: (_, second) => second, | ||
combineMany: (start, others) => { | ||
let a: A = start | ||
// eslint-disable-next-line no-empty | ||
for (a of others) {} | ||
return a | ||
} | ||
combine: (second) => () => second, | ||
combineMany: (collection) => | ||
(self) => { | ||
let a: A = self | ||
// eslint-disable-next-line no-empty | ||
for (a of collection) {} | ||
return a | ||
} | ||
}) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -12,3 +12,3 @@ import type { Functor } from "@fp-ts/core/Functor" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,12 +20,10 @@ export interface Semigroupal<F extends TypeLambda> extends Functor<F> { | ||
*/ | ||
readonly zipWith: <S, R1, O1, E1, A, R2, O2, E2, B, C>( | ||
fa: Kind<F, S, R1, O1, E1, A>, | ||
fb: Kind<F, S, R2, O2, E2, B>, | ||
readonly zipWith: <S, R2, O2, E2, B, A, C>( | ||
that: Kind<F, S, R2, O2, E2, B>, | ||
f: (a: A, b: B) => C | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C> | ||
) => <R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C> | ||
readonly zipMany: <S, R, O, E, A>( | ||
start: Kind<F, S, R, O, E, A>, | ||
others: Iterable<Kind<F, S, R, O, E, A>> | ||
) => Kind<F, S, R, O, E, [A, ...ReadonlyArray<A>]> | ||
collection: Iterable<Kind<F, S, R, O, E, A>> | ||
) => (self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, readonly [A, ...ReadonlyArray<A>]> | ||
} | ||
@@ -36,3 +34,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -43,17 +41,16 @@ export const zipWithComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
) => | ||
<FS, FR1, FO1, FE1, GS, GR1, GO1, GE1, A, FR2, FO2, FE2, GR2, GO2, GE2, B, C>( | ||
fga: Kind<F, FS, FR1, FO1, FE1, Kind<G, GS, GR1, GO1, GE1, A>>, | ||
fgb: Kind<F, FS, FR2, FO2, FE2, Kind<G, GS, GR2, GO2, GE2, B>>, | ||
<FS, FR2, FO2, FE2, GS, GR2, GO2, GE2, B, A, C>( | ||
that: Kind<F, FS, FR2, FO2, FE2, Kind<G, GS, GR2, GO2, GE2, B>>, | ||
f: (a: A, b: B) => C | ||
): Kind< | ||
F, | ||
FS, | ||
FR1 & FR2, | ||
FO1 | FO2, | ||
FE1 | FE2, | ||
Kind<G, GS, GR1 & GR2, GO1 | GO2, GE1 | GE2, C> | ||
> => | ||
pipe( | ||
SemigroupalF.zipWith(fga, fgb, (ga, gb) => SemigroupalG.zipWith(ga, gb, f)) | ||
) | ||
) => | ||
<FR1, FO1, FE1, GR1, GO1, GE1>( | ||
self: Kind<F, FS, FR1, FO1, FE1, Kind<G, GS, GR1, GO1, GE1, A>> | ||
): Kind< | ||
F, | ||
FS, | ||
FR1 & FR2, | ||
FO1 | FO2, | ||
FE1 | FE2, | ||
Kind<G, GS, GR1 & GR2, GO1 | GO2, GE1 | GE2, C> | ||
> => pipe(self, SemigroupalF.zipWith(that, (ga, gb) => pipe(ga, SemigroupalG.zipWith(gb, f)))) | ||
@@ -63,3 +60,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -71,22 +68,27 @@ export const zipManyComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
<FS, FR, FO, FE, GS, GR, GO, GE, A>( | ||
start: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>, | ||
others: Iterable<Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>> | ||
): Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, [A, ...ReadonlyArray<A>]>> => | ||
pipe( | ||
SemigroupalF.zipMany(start, others), | ||
SemigroupalF.map(([ga, ...gas]) => SemigroupalG.zipMany(ga, gas)) | ||
) | ||
collection: Iterable<Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>> | ||
) => | ||
( | ||
self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>> | ||
): Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, readonly [A, ...ReadonlyArray<A>]>> => | ||
pipe( | ||
self, | ||
SemigroupalF.zipMany(collection), | ||
SemigroupalF.map(([ga, ...gas]) => SemigroupalG.zipMany(gas)(ga)) | ||
) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const ap = <F extends TypeLambda>(Semigroupal: Semigroupal<F>): <S, R2, O2, E2, A>( | ||
fa: Kind<F, S, R2, O2, E2, A> | ||
) => <R1, O1, E1, B>( | ||
self: Kind<F, S, R1, O1, E1, (a: A) => B> | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, B> => | ||
fa => fab => Semigroupal.zipWith(fa, fab, (a, f) => f(a)) | ||
export const ap = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
<S, R2, O2, E2, A>( | ||
fa: Kind<F, S, R2, O2, E2, A> | ||
) => | ||
<R1, O1, E1, B>( | ||
self: Kind<F, S, R1, O1, E1, (a: A) => B> | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, B> => | ||
pipe(self, Semigroupal.zipWith(fa, (f, a) => f(a))) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -98,3 +100,3 @@ export const zip = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, readonly [A, B]> => | ||
Semigroupal.zipWith(self, that, (a, b) => [a, b]) | ||
pipe(self, Semigroupal.zipWith(that, (a, b) => [a, b])) | ||
@@ -105,3 +107,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -111,3 +113,3 @@ export const zipWith = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
<R1, O1, E1>(self: Kind<F, S, R1, O1, E1, A>): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C> => | ||
Semigroupal.zipWith(self, that, f) | ||
pipe(self, Semigroupal.zipWith(that, f)) | ||
@@ -119,3 +121,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -128,3 +130,3 @@ export const zipLeftPar = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
self: Kind<F, S, R1, O1, E1, A> | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A> => Semigroupal.zipWith(self, that, identity) | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A> => pipe(self, Semigroupal.zipWith(that, identity)) | ||
@@ -136,3 +138,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -145,3 +147,4 @@ export const zipRightPar = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
self: Kind<F, S, R1, O1, E1, unknown> | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A> => Semigroupal.zipWith(self, that, (_, a) => a) | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A> => | ||
pipe(self, Semigroupal.zipWith(that, (_, a) => a)) | ||
@@ -151,3 +154,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -168,3 +171,3 @@ export const bindRight = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
{ readonly [K in keyof A | N]: K extends keyof A ? A[K] : B } | ||
> => Semigroupal.zipWith(self, fb, (a, b) => Object.assign({}, a, { [name]: b }) as any) | ||
> => pipe(self, Semigroupal.zipWith(fb, (a, b) => Object.assign({}, a, { [name]: b }) as any)) | ||
@@ -174,3 +177,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -184,3 +187,3 @@ export const zipFlatten = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, readonly [...A, B]> => | ||
Semigroupal.zipWith(self, that, (a, b) => [...a, b] as const) | ||
pipe(self, Semigroupal.zipWith(that, (a, b) => [...a, b] as const)) | ||
@@ -190,7 +193,9 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const liftSemigroup = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
<A, S, R, O, E>(Semigroup: Semigroup<A>): Semigroup<Kind<F, S, R, O, E, A>> => | ||
semigroup.fromCombine((first, second) => Semigroupal.zipWith(first, second, Semigroup.combine)) | ||
semigroup.fromCombine((that) => | ||
(self) => pipe(self, Semigroupal.zipWith(that, (a1, a2) => Semigroup.combine(a2)(a1))) | ||
) | ||
@@ -200,3 +205,3 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -208,6 +213,6 @@ export const lift2 = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
fb: Kind<F, S, R2, O2, E2, B> | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C> => Semigroupal.zipWith(fa, fb, f) | ||
): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, C> => pipe(fa, Semigroupal.zipWith(fb, f)) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -222,4 +227,4 @@ const zip3With = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => | ||
pipe( | ||
fa, | ||
Semigroupal.zipMany<S, R1, O1, E1, any>( | ||
fa, | ||
[fb, fc] as any | ||
@@ -233,3 +238,3 @@ ), | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -236,0 +241,0 @@ export const lift3 = <F extends TypeLambda>(Semigroupal: Semigroupal<F>) => |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,14 +9,14 @@ import type { Functor } from "@fp-ts/core/Functor" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface SemigroupKind<F extends TypeLambda> extends Functor<F> { | ||
readonly combineKind: <S, R, O, E, A, B>( | ||
first: Kind<F, S, R, O, E, A>, | ||
second: Kind<F, S, R, O, E, A> | ||
) => Kind<F, S, R, O, E, A | B> | ||
readonly combineKind: <S, R2, O2, E2, B>( | ||
that: Kind<F, S, R2, O2, E2, B> | ||
) => <R1, O1, E1, A>( | ||
self: Kind<F, S, R1, O1, E1, A> | ||
) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, A | B> | ||
readonly combineKindMany: <S, R, O, E, A>( | ||
start: Kind<F, S, R, O, E, A>, | ||
others: Iterable<Kind<F, S, R, O, E, A>> | ||
) => Kind<F, S, R, O, E, A> | ||
collection: Iterable<Kind<F, S, R, O, E, A>> | ||
) => (self: Kind<F, S, R, O, E, A>) => Kind<F, S, R, O, E, A> | ||
} |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -13,6 +13,6 @@ import type * as contravariant from "@fp-ts/core/Contravariant" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export interface Sortable<A> { | ||
readonly compare: (first: A, second: A) => Ordering | ||
readonly compare: (that: A) => (self: A) => Ordering | ||
} | ||
@@ -22,3 +22,3 @@ | ||
* @category type lambdas | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -31,6 +31,6 @@ export interface SortableTypeLambda extends TypeLambda { | ||
* @category constructors | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const fromCompare = <A>(compare: Sortable<A>["compare"]): Sortable<A> => ({ | ||
compare: (first, second) => first === second ? 0 : compare(first, second) | ||
compare: (that) => (self) => self === that ? 0 : compare(that)(self) | ||
}) | ||
@@ -41,3 +41,3 @@ | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -47,53 +47,60 @@ export const tuple = <A extends ReadonlyArray<unknown>>( | ||
): Sortable<Readonly<A>> => | ||
fromCompare((first, second) => { | ||
let i = 0 | ||
for (; i < compares.length - 1; i++) { | ||
const r = compares[i].compare(first[i], second[i]) | ||
if (r !== 0) { | ||
return r | ||
fromCompare((that) => | ||
(self) => { | ||
let i = 0 | ||
for (; i < compares.length - 1; i++) { | ||
const r = compares[i].compare(that[i])(self[i]) | ||
if (r !== 0) { | ||
return r | ||
} | ||
} | ||
return compares[i].compare(that[i])(self[i]) | ||
} | ||
return compares[i].compare(first[i], second[i]) | ||
}) | ||
) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const reverse = <A>(Sortable: Sortable<A>): Sortable<A> => | ||
fromCompare((first, second) => Sortable.compare(second, first)) | ||
fromCompare((that) => (self) => Sortable.compare(self)(that)) | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const contramap = <B, A>(f: (b: B) => A) => | ||
(self: Sortable<A>): Sortable<B> => | ||
fromCompare((first, second) => self.compare(f(first), f(second))) | ||
(self: Sortable<A>): Sortable<B> => fromCompare((b2) => (b1) => self.compare(f(b2))(f(b1))) | ||
/** | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const getSemigroup = <A>(): Semigroup<Sortable<A>> => ({ | ||
combine: (s1, s2) => | ||
fromCompare((first, second) => { | ||
const out = s1.compare(first, second) | ||
if (out !== 0) { | ||
return out | ||
} | ||
return s2.compare(first, second) | ||
}), | ||
combineMany: (start, others) => | ||
fromCompare((first, second) => { | ||
let out = start.compare(first, second) | ||
if (out !== 0) { | ||
return out | ||
} | ||
for (const sortable of others) { | ||
out = sortable.compare(first, second) | ||
if (out !== 0) { | ||
combine: (sortable2) => | ||
(sortable1) => | ||
fromCompare((that) => | ||
(self) => { | ||
const out = sortable1.compare(that)(self) | ||
if (out !== 0) { | ||
return out | ||
} | ||
return sortable2.compare(that)(self) | ||
} | ||
), | ||
combineMany: (collection) => | ||
(self) => | ||
fromCompare((a2) => | ||
(a1) => { | ||
let out = self.compare(a2)(a1) | ||
if (out !== 0) { | ||
return out | ||
} | ||
for (const sortable of collection) { | ||
out = sortable.compare(a2)(a1) | ||
if (out !== 0) { | ||
return out | ||
} | ||
} | ||
return out | ||
} | ||
} | ||
return out | ||
}) | ||
) | ||
}) | ||
@@ -103,10 +110,10 @@ | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const getMonoid = <A>(): Monoid<Sortable<A>> => | ||
monoid.fromSemigroup(getSemigroup<A>(), fromCompare(() => 0)) | ||
monoid.fromSemigroup(getSemigroup<A>(), fromCompare(() => () => 0)) | ||
/** | ||
* @category instances | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -120,6 +127,6 @@ export const Contravariant: contravariant.Contravariant<SortableTypeLambda> = { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const lt = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A) => Sortable.compare(first, second) === -1 | ||
(that: A) => (self: A) => Sortable.compare(that)(self) === -1 | ||
@@ -129,6 +136,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const gt = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A) => Sortable.compare(first, second) === 1 | ||
(that: A) => (self: A) => Sortable.compare(that)(self) === 1 | ||
@@ -138,6 +145,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const leq = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A) => Sortable.compare(first, second) !== 1 | ||
(that: A) => (self: A) => Sortable.compare(that)(self) !== 1 | ||
@@ -147,6 +154,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const geq = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A) => Sortable.compare(first, second) !== -1 | ||
(that: A) => (self: A) => Sortable.compare(that)(self) !== -1 | ||
@@ -156,7 +163,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const min = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A): A => | ||
first === second || Sortable.compare(first, second) < 1 ? first : second | ||
(that: A) => (self: A): A => self === that || Sortable.compare(that)(self) < 1 ? self : that | ||
@@ -166,7 +172,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const max = <A>(Sortable: Sortable<A>) => | ||
(first: A, second: A): A => | ||
first === second || Sortable.compare(first, second) > -1 ? first : second | ||
(that: A) => (self: A): A => self === that || Sortable.compare(that)(self) > -1 ? self : that | ||
@@ -176,9 +181,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const clamp = <A>(Sortable: Sortable<A>) => { | ||
const min_ = min(Sortable) | ||
const max_ = max(Sortable) | ||
return (minimum: A, maximum: A) => (a: A) => min_(maximum, max_(minimum, a)) | ||
} | ||
export const clamp = <A>(Sortable: Sortable<A>) => | ||
(minimum: A, maximum: A) => (a: A) => min(Sortable)(max(Sortable)(a)(minimum))(maximum) | ||
@@ -188,8 +190,6 @@ /** | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export const between = <A>(Sortable: Sortable<A>) => { | ||
const lt_ = lt(Sortable) | ||
const gt_ = gt(Sortable) | ||
return (minimum: A, maximum: A) => (a: A): boolean => !lt_(a, minimum) && !gt_(a, maximum) | ||
} | ||
export const between = <A>(Sortable: Sortable<A>) => | ||
(minimum: A, maximum: A) => | ||
(a: A): boolean => !lt(Sortable)(minimum)(a) && !gt(Sortable)(maximum)(a) |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -10,3 +10,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -26,3 +26,3 @@ export interface Traversable<T extends TypeLambda> extends TypeClass<T> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -42,3 +42,3 @@ export const traverseComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -45,0 +45,0 @@ export const sequence = <T extends TypeLambda>(Traversable: Traversable<T>) => |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -9,3 +9,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -25,3 +25,3 @@ export interface TraversableWithIndex<T extends TypeLambda, I> extends TypeClass<T> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -28,0 +28,0 @@ export const traverseWithIndexComposition = <F extends TypeLambda, I, G extends TypeLambda, J>( |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,9 +17,9 @@ export interface Traversable<T extends TypeLambda> extends TypeClass<T> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const traverseComposition: <F extends TypeLambda, G extends TypeLambda>(TraversableF: Traversable<F>, TraversableG: Traversable<G>) => <H extends TypeLambda>(H: Monoidal<H>) => <A, S, R, O, E, B>(f: (a: A) => Kind<H, S, R, O, E, B>) => <FS, FR, FO, FE, GS, GR, GO, GE>(fga: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => Kind<H, S, R, O, E, Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, B>>>; | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const sequence: <T extends TypeLambda>(Traversable: Traversable<T>) => <F extends TypeLambda>(G: Monoidal<F>) => <TS, TR, TO, TE, S, R, O, E, A>(self: Kind<T, TS, TR, TO, TE, Kind<F, S, R, O, E, A>>) => Kind<F, S, R, O, E, Kind<T, TS, TR, TO, TE, A>>; | ||
//# sourceMappingURL=Traversable.d.ts.map |
@@ -13,7 +13,7 @@ "use strict"; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
const traverseComposition = (TraversableF, TraversableG) => H => f => TraversableF.traverse(H)(TraversableG.traverse(H)(f)); | ||
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -20,0 +20,0 @@ |
/** | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -8,3 +8,3 @@ import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT"; | ||
* @category type class | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -17,5 +17,5 @@ export interface TraversableWithIndex<T extends TypeLambda, I> extends TypeClass<T> { | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
export declare const traverseWithIndexComposition: <F extends TypeLambda, I, G extends TypeLambda, J>(TraversableWithIndexF: TraversableWithIndex<F, I>, TraversableWithIndexG: TraversableWithIndex<G, J>) => <H extends TypeLambda>(H: Monoidal<H>) => <A, S, R, O, E, B>(f: (a: A, ij: readonly [I, J]) => Kind<H, S, R, O, E, B>) => <FS, FR, FO, FE, GS, GR, GO, GE>(fga: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => Kind<H, S, R, O, E, Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, B>>>; | ||
//# sourceMappingURL=TraversableWithIndex.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
* | ||
* @since 3.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
@@ -14,0 +14,0 @@ const traverseWithIndexComposition = (TraversableWithIndexF, TraversableWithIndexG) => H => f => TraversableWithIndexF.traverseWithIndex(H)((ga, i) => TraversableWithIndexG.traverseWithIndex(H)((a, j) => f(a, [i, j]))(ga)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
230123
205
4451