@fp-ts/core
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -11,4 +11,4 @@ /** | ||
export interface Bounded<A> extends Sortable<A> { | ||
readonly minimum: A; | ||
readonly maximum: A; | ||
readonly minimum: A; | ||
} | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
export declare const fromSortable: <A>(Sortable: compare.Sortable<A>, maximum: A, minimum: A) => Bounded<A>; | ||
export declare const fromSortable: <A>(Sortable: compare.Sortable<A>, minimum: A, maximum: A) => Bounded<A>; | ||
/** | ||
@@ -26,3 +26,3 @@ * Clamp a value between `minimum` and `maximum` values. | ||
*/ | ||
export declare const clamp: <A>(B: Bounded<A>) => (a: A) => A; | ||
export declare const clamp: <A>(Bounded: Bounded<A>) => (a: A) => A; | ||
/** | ||
@@ -29,0 +29,0 @@ * Reverses the `Ord` of a `Bounded` and flips `maximum` and `minimum` values. |
@@ -22,3 +22,3 @@ "use strict"; | ||
*/ | ||
const fromSortable = (Sortable, maximum, minimum) => ({ ...Sortable, | ||
const fromSortable = (Sortable, minimum, maximum) => ({ ...Sortable, | ||
maximum, | ||
@@ -36,3 +36,3 @@ minimum | ||
const clamp = B => compare.clamp(B)(B.minimum, B.maximum); | ||
const clamp = Bounded => compare.clamp(Bounded)(Bounded.minimum, Bounded.maximum); | ||
/** | ||
@@ -39,0 +39,0 @@ * Reverses the `Ord` of a `Bounded` and flips `maximum` and `minimum` values. |
@@ -15,9 +15,25 @@ /** | ||
/** | ||
* Returns a default `reduce` composition. | ||
* | ||
* @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[]; | ||
export declare const reduceComposition: <F extends TypeLambda, G extends TypeLambda>(F: Foldable<F>, G: Foldable<G>) => <B, A>(b: B, f: (b: B, 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>>) => B; | ||
/** | ||
* Returns a default `reduceRight` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export declare const reduceRightComposition: <F extends TypeLambda, G extends TypeLambda>(F: Foldable<F>, G: Foldable<G>) => <B, A>(b: B, f: (b: B, 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>>) => B; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArray: <F extends TypeLambda>(Foldable: Foldable<F>) => <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => readonly A[]; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArrayWith: <F extends TypeLambda>(Foldable: Foldable<F>) => <A, B>(f: (a: A) => B) => <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => 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,4 +6,6 @@ "use strict"; | ||
}); | ||
exports.toReadonlyArrayWith = exports.foldMap = void 0; | ||
exports.toReadonlyArrayWith = exports.toReadonlyArray = exports.reduceRightComposition = exports.reduceComposition = exports.foldMap = void 0; | ||
var _Function = /*#__PURE__*/require("@fp-ts/core/internal/Function"); | ||
/** | ||
@@ -14,5 +16,33 @@ * @since 1.0.0 | ||
/** | ||
* Returns a default `reduce` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
const toReadonlyArrayWith = Foldable => (self, f) => Foldable.reduce([], (out, a) => { | ||
const reduceComposition = (F, G) => (b, f) => self => (0, _Function.pipe)(self, F.reduce(b, (b, ga) => (0, _Function.pipe)(ga, G.reduce(b, f)))); | ||
/** | ||
* Returns a default `reduceRight` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
exports.reduceComposition = reduceComposition; | ||
const reduceRightComposition = (F, G) => (b, f) => self => (0, _Function.pipe)(self, F.reduceRight(b, (b, ga) => (0, _Function.pipe)(ga, G.reduceRight(b, f)))); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.reduceRightComposition = reduceRightComposition; | ||
const toReadonlyArray = Foldable => toReadonlyArrayWith(Foldable)(_Function.identity); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.toReadonlyArray = toReadonlyArray; | ||
const toReadonlyArrayWith = Foldable => f => self => Foldable.reduce([], (out, a) => { | ||
out.push(f(a)); | ||
@@ -28,5 +58,5 @@ return out; | ||
const foldMap = Foldable => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(Foldable)(self, f)); | ||
const foldMap = Foldable => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(Foldable)(f)(self)); | ||
exports.foldMap = foldMap; | ||
//# sourceMappingURL=Foldable.js.map |
@@ -15,9 +15,25 @@ /** | ||
/** | ||
* Returns a default `reduceWithIndex` composition. | ||
* | ||
* @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[]; | ||
export declare const reduceWithIndexComposition: <F extends TypeLambda, I, G extends TypeLambda, J>(F: FoldableWithIndex<F, I>, G: FoldableWithIndex<G, J>) => <B, A>(b: B, f: (b: B, a: A, ij: readonly [I, J]) => B) => <FS, FR, FO, FE, GS, GR, GO, GE>(self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => B; | ||
/** | ||
* Returns a default `reduceRightWithIndex` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export declare const reduceRightWithIndexComposition: <F extends TypeLambda, I, G extends TypeLambda, J>(F: FoldableWithIndex<F, I>, G: FoldableWithIndex<G, J>) => <B, A>(b: B, f: (b: B, a: A, ij: readonly [I, J]) => B) => <FS, FR, FO, FE, GS, GR, GO, GE>(self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>>) => B; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArray: <F extends TypeLambda, I>(FoldableWithIndex: FoldableWithIndex<F, I>) => <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => readonly A[]; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const toReadonlyArrayWith: <F extends TypeLambda, I>(FoldableWithIndex: FoldableWithIndex<F, I>) => <A, B>(f: (a: A, i: I) => B) => <S, R, O, E>(self: Kind<F, S, R, O, E, A>) => 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,4 +6,6 @@ "use strict"; | ||
}); | ||
exports.toReadonlyArrayWith = exports.foldMapWithIndex = void 0; | ||
exports.toReadonlyArrayWith = exports.toReadonlyArray = exports.reduceWithIndexComposition = exports.reduceRightWithIndexComposition = exports.foldMapWithIndex = void 0; | ||
var _Function = /*#__PURE__*/require("@fp-ts/core/internal/Function"); | ||
/** | ||
@@ -14,5 +16,33 @@ * @since 1.0.0 | ||
/** | ||
* Returns a default `reduceWithIndex` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
const toReadonlyArrayWith = FoldableWithIndex => (self, f) => FoldableWithIndex.reduceWithIndex([], (out, a, i) => { | ||
const reduceWithIndexComposition = (F, G) => (b, f) => self => (0, _Function.pipe)(self, F.reduceWithIndex(b, (b, ga, i) => (0, _Function.pipe)(ga, G.reduceWithIndex(b, (b, a, j) => f(b, a, [i, j]))))); | ||
/** | ||
* Returns a default `reduceRightWithIndex` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
exports.reduceWithIndexComposition = reduceWithIndexComposition; | ||
const reduceRightWithIndexComposition = (F, G) => (b, f) => self => (0, _Function.pipe)(self, F.reduceRightWithIndex(b, (b, ga, i) => (0, _Function.pipe)(ga, G.reduceRightWithIndex(b, (b, a, j) => f(b, a, [i, j]))))); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.reduceRightWithIndexComposition = reduceRightWithIndexComposition; | ||
const toReadonlyArray = FoldableWithIndex => toReadonlyArrayWith(FoldableWithIndex)(_Function.identity); | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.toReadonlyArray = toReadonlyArray; | ||
const toReadonlyArrayWith = FoldableWithIndex => f => self => FoldableWithIndex.reduceWithIndex([], (out, a, i) => { | ||
out.push(f(a, i)); | ||
@@ -28,5 +58,5 @@ return out; | ||
const foldMapWithIndex = FoldableWithIndex => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(self, f)); | ||
const foldMapWithIndex = FoldableWithIndex => Monoid => f => self => Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(f)(self)); | ||
exports.foldMapWithIndex = foldMapWithIndex; | ||
//# sourceMappingURL=FoldableWithIndex.js.map |
@@ -17,2 +17,3 @@ /** | ||
import * as functor from "@fp-ts/core/Functor"; | ||
import * as functorWithIndex from "@fp-ts/core/FunctorWithIndex"; | ||
import * as hkt from "@fp-ts/core/HKT"; | ||
@@ -99,4 +100,9 @@ import * as invariant from "@fp-ts/core/Invariant"; | ||
/** | ||
* @category type classes | ||
* @since 1.0.0 | ||
*/ | ||
functorWithIndex, | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
hkt, | ||
@@ -103,0 +109,0 @@ /** |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
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; | ||
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.functorWithIndex = 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; | ||
@@ -61,2 +61,6 @@ var bifunctor = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/Bifunctor")); | ||
var functorWithIndex = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/FunctorWithIndex")); | ||
exports.functorWithIndex = functorWithIndex; | ||
var hkt = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fp-ts/core/HKT")); | ||
@@ -63,0 +67,0 @@ |
{ | ||
"name": "@fp-ts/core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -19,10 +19,8 @@ <h3 align="center"> | ||
This is a fork of [`fp-ts`](https://github.com/gcanti/fp-ts). | ||
This project represents the next major iteration of [`fp-ts`](https://github.com/gcanti/fp-ts) and it's objective is a reconciliation with [`Effect`](https://github.com/Effect-TS) in order to unify the ecosystems. | ||
The goal of this fork is a potential reconciliation with [`Effect-TS`](https://github.com/Effect-TS) in order to unify the ecosystems. | ||
The [`Effect`](https://github.com/Effect-TS) project will reduce it's scope to simply being an effect system and will delegate to `fp-ts org` all the lower level abstractions such as typeclasses and common data structures. | ||
The [`Effect-TS`](https://github.com/Effect-TS) project will reduce it's scope to simply being an effect system and will delegate to `fp-ts org` all the lower level abstractions such as typeclasses and common data structures. | ||
The objective of the `fp-ts org` in github and in npm (`@fp-ts`) is to simplify structure and management of the project, have smaller and better scoped packages. | ||
The objective of the `fp-ts org` in github and in npm (`@fp-ts`) is to simplify structure and management of the project, have smaller and better scoped packages and it represents the next major iteration of [`fp-ts`](https://github.com/gcanti/fp-ts). | ||
Our "current" idea (that is well open for changes) is for `fp-ts org` to have: | ||
@@ -35,3 +33,3 @@ | ||
And for [`Effect-TS`](https://github.com/Effect-TS) to have: | ||
And for [`Effect`](https://github.com/Effect-TS) to have: | ||
@@ -42,3 +40,3 @@ - `@effect/core` with the effect system | ||
Note that [`Effect-TS`](https://github.com/Effect-TS) will not have base structures and typeclasses and `fp-ts org` will not have `Task` / `IO` /etc as both projects are made to be the same ecosystem and each answer a specific set of needs well. | ||
Note that [`Effect`](https://github.com/Effect-TS) will not have base structures like `Option` / `Result` / `List` and typeclasses like `Monad` / `Functor` and [`fp-ts`](https://github.com/fp-ts) will not have effect execution modules like `Task` / `IO` as both projects are made to be the same ecosystem and each answer a specific set of needs in the best way possible. | ||
@@ -45,0 +43,0 @@ # Installation |
@@ -74,6 +74,6 @@ "use strict"; | ||
const reverse = Semigroup => ({ | ||
combine: that => self => Semigroup.combine(that)(self), | ||
combine: that => self => Semigroup.combine(self)(that), | ||
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))); | ||
return reversed.length === 0 ? self : Semigroup.combine(self)(Semigroup.combineMany(reversed.slice(1))(reversed[0])); | ||
} | ||
@@ -80,0 +80,0 @@ }); |
@@ -40,9 +40,2 @@ /** | ||
/** | ||
* Zips this effect with the specified effect using the | ||
* specified combiner function. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
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>; | ||
/** | ||
* Returns an effect that executes both this effect and the specified effect, | ||
@@ -49,0 +42,0 @@ * in parallel, this effect result returned. If either side fails, then the |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.zipWithComposition = exports.zipWith = exports.zipRightPar = exports.zipManyComposition = exports.zipLeftPar = exports.zipFlatten = exports.zip = exports.liftSemigroup = exports.lift3 = exports.lift2 = exports.bindRight = exports.ap = void 0; | ||
exports.zipWithComposition = exports.zipRightPar = exports.zipManyComposition = exports.zipLeftPar = exports.zipFlatten = exports.zip = exports.liftSemigroup = exports.lift3 = exports.lift2 = exports.bindRight = exports.ap = void 0; | ||
@@ -50,13 +50,2 @@ var _Function = /*#__PURE__*/require("@fp-ts/core/internal/Function"); | ||
/** | ||
* Zips this effect with the specified effect using the | ||
* specified combiner function. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
exports.zip = zip; | ||
const zipWith = Semigroupal => (that, f) => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, f)); | ||
/** | ||
* Returns an effect that executes both this effect and the specified effect, | ||
@@ -70,3 +59,3 @@ * in parallel, this effect result returned. If either side fails, then the | ||
exports.zipWith = zipWith; | ||
exports.zip = zip; | ||
@@ -73,0 +62,0 @@ const zipLeftPar = Semigroupal => that => self => (0, _Function.pipe)(self, Semigroupal.zipWith(that, _Function.identity)); |
@@ -12,4 +12,4 @@ /** | ||
export interface Bounded<A> extends Sortable<A> { | ||
readonly minimum: A | ||
readonly maximum: A | ||
readonly minimum: A | ||
} | ||
@@ -21,3 +21,3 @@ | ||
*/ | ||
export const fromSortable = <A>(Sortable: Sortable<A>, maximum: A, minimum: A): Bounded<A> => ({ | ||
export const fromSortable = <A>(Sortable: Sortable<A>, minimum: A, maximum: A): Bounded<A> => ({ | ||
...Sortable, | ||
@@ -33,3 +33,4 @@ maximum, | ||
*/ | ||
export const clamp = <A>(B: Bounded<A>): (a: A) => A => compare.clamp(B)(B.minimum, B.maximum) | ||
export const clamp = <A>(Bounded: Bounded<A>): (a: A) => A => | ||
compare.clamp(Bounded)(Bounded.minimum, Bounded.maximum) | ||
@@ -36,0 +37,0 @@ /** |
@@ -6,2 +6,3 @@ /** | ||
import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
import { identity, pipe } from "@fp-ts/core/internal/Function" | ||
import type { Monoid } from "@fp-ts/core/Monoid" | ||
@@ -26,12 +27,49 @@ | ||
/** | ||
* Returns a default `reduce` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export const reduceComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
F: Foldable<F>, | ||
G: Foldable<G> | ||
) => | ||
<B, A>(b: B, f: (b: B, 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>> | ||
): B => pipe(self, F.reduce(b, (b, ga) => pipe(ga, G.reduce(b, f)))) | ||
/** | ||
* Returns a default `reduceRight` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export const reduceRightComposition = <F extends TypeLambda, G extends TypeLambda>( | ||
F: Foldable<F>, | ||
G: Foldable<G> | ||
) => | ||
<B, A>(b: B, f: (b: B, 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>> | ||
): B => pipe(self, F.reduceRight(b, (b, ga) => pipe(ga, G.reduceRight(b, f)))) | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export const toReadonlyArray = <F extends TypeLambda>( | ||
Foldable: Foldable<F> | ||
): <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => ReadonlyArray<A> => | ||
toReadonlyArrayWith(Foldable)(identity) | ||
/** | ||
* @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) | ||
<A, B>(f: (a: A) => B) => | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): ReadonlyArray<B> => | ||
Foldable.reduce<A, Array<B>>([], (out, a) => { | ||
out.push(f(a)) | ||
return out | ||
})(self) | ||
@@ -45,2 +83,2 @@ /** | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): M => | ||
Monoid.combineAll(toReadonlyArrayWith(Foldable)(self, f)) | ||
Monoid.combineAll(toReadonlyArrayWith(Foldable)(f)(self)) |
@@ -6,2 +6,3 @@ /** | ||
import type { Kind, TypeClass, TypeLambda } from "@fp-ts/core/HKT" | ||
import { identity, pipe } from "@fp-ts/core/internal/Function" | ||
import type { Monoid } from "@fp-ts/core/Monoid" | ||
@@ -26,12 +27,59 @@ | ||
/** | ||
* Returns a default `reduceWithIndex` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export const reduceWithIndexComposition = <F extends TypeLambda, I, G extends TypeLambda, J>( | ||
F: FoldableWithIndex<F, I>, | ||
G: FoldableWithIndex<G, J> | ||
) => | ||
<B, A>(b: B, f: (b: B, a: A, ij: readonly [I, J]) => B) => | ||
<FS, FR, FO, FE, GS, GR, GO, GE>( | ||
self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>> | ||
): B => | ||
pipe( | ||
self, | ||
F.reduceWithIndex(b, (b, ga, i) => | ||
pipe(ga, G.reduceWithIndex(b, (b, a, j) => f(b, a, [i, j])))) | ||
) | ||
/** | ||
* Returns a default `reduceRightWithIndex` composition. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export const reduceRightWithIndexComposition = <F extends TypeLambda, I, G extends TypeLambda, J>( | ||
F: FoldableWithIndex<F, I>, | ||
G: FoldableWithIndex<G, J> | ||
) => | ||
<B, A>(b: B, f: (b: B, a: A, ij: readonly [I, J]) => B) => | ||
<FS, FR, FO, FE, GS, GR, GO, GE>( | ||
self: Kind<F, FS, FR, FO, FE, Kind<G, GS, GR, GO, GE, A>> | ||
): B => | ||
pipe( | ||
self, | ||
F.reduceRightWithIndex(b, (b, ga, i) => | ||
pipe(ga, G.reduceRightWithIndex(b, (b, a, j) => f(b, a, [i, j])))) | ||
) | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export const toReadonlyArray = <F extends TypeLambda, I>( | ||
FoldableWithIndex: FoldableWithIndex<F, I> | ||
): <S, R, O, E, A>(self: Kind<F, S, R, O, E, A>) => ReadonlyArray<A> => | ||
toReadonlyArrayWith(FoldableWithIndex)(identity) | ||
/** | ||
* @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) | ||
<A, B>(f: (a: A, i: I) => B) => | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): ReadonlyArray<B> => | ||
FoldableWithIndex.reduceWithIndex<A, Array<B>>([], (out, a, i) => { | ||
out.push(f(a, i)) | ||
return out | ||
})(self) | ||
@@ -47,2 +95,2 @@ /** | ||
<S, R, O, E>(self: Kind<F, S, R, O, E, A>): M => | ||
Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(self, f)) | ||
Monoid.combineAll(toReadonlyArrayWith(FoldableWithIndex)(f)(self)) |
@@ -18,2 +18,3 @@ /** | ||
import * as functor from "@fp-ts/core/Functor" | ||
import * as functorWithIndex from "@fp-ts/core/FunctorWithIndex" | ||
import * as hkt from "@fp-ts/core/HKT" | ||
@@ -101,4 +102,9 @@ import * as invariant from "@fp-ts/core/Invariant" | ||
/** | ||
* @category type classes | ||
* @since 1.0.0 | ||
*/ | ||
functorWithIndex, | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
hkt, | ||
@@ -105,0 +111,0 @@ /** |
@@ -65,3 +65,3 @@ /** | ||
export const reverse = <A>(Semigroup: Semigroup<A>): Semigroup<A> => ({ | ||
combine: (that) => (self) => Semigroup.combine(that)(self), | ||
combine: (that) => (self) => Semigroup.combine(self)(that), | ||
combineMany: (collection) => | ||
@@ -72,5 +72,3 @@ (self) => { | ||
self : | ||
Semigroup.combine(self)( | ||
reversed.reduceRight((first, second) => Semigroup.combine(second)(first)) | ||
) | ||
Semigroup.combine(self)(Semigroup.combineMany(reversed.slice(1))(reversed[0])) | ||
} | ||
@@ -77,0 +75,0 @@ }) |
@@ -97,13 +97,2 @@ /** | ||
/** | ||
* Zips this effect with the specified effect using the | ||
* specified combiner function. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
export 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, O1 | O2, E1 | E2, C> => | ||
pipe(self, Semigroupal.zipWith(that, f)) | ||
/** | ||
* Returns an effect that executes both this effect and the specified effect, | ||
@@ -110,0 +99,0 @@ * in parallel, this effect result returned. If either side fails, then the |
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
245112
212
4693
55