Socket
Socket
Sign inDemoInstall

fp-ts

Package Overview
Dependencies
Maintainers
1
Versions
231
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fp-ts - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

lib-jsnext/IxMonad.d.ts

13

CHANGELOG.md

@@ -15,2 +15,15 @@ # Changelog

# 0.2.8
- **New Feature**
- Monoid: add `getFunctionStaticMonoid`, closes #70 (@gcanti)
- Foldable: add `traverse_` and `sequence_`, closes #71 (@gcanti)
- add `getStaticMonad` to `EitherT`, `OptionT`, `ReaderT`, closes #81 (@gcanti)
- Applicative: add `when`, closes #77 (@gcanti)
- indexed monad type class and `IxMonadT`, closes #73 (@gcanti)
- Array / function: add refinements, closes #68 (@gcanti, @sledorze)
- **Bug Fix**
- Either: `of` should return `Either`, fix #80 (@gcanti)
- fix `toArray` (@gcanti)
# 0.2.7

@@ -17,0 +30,0 @@

4

lib-jsnext/Applicative.d.ts

@@ -1,2 +0,2 @@

import { HKTS } from './HKT';
import { HKT, HKTS } from './HKT';
import { StaticPointed, FantasyPointed } from './Pointed';

@@ -10,1 +10,3 @@ import { StaticApply, FantasyApply } from './Apply';

export declare function getApplicativeComposition<FG extends HKTS>(URI: FG): <F extends HKTS, G extends HKTS>(applicativeF: StaticApplicative<F>, applicativeG: StaticApplicative<G>) => StaticApplicative<FG>;
/** Perform a applicative action when a condition is true */
export declare function when<F extends HKTS>(applicative: StaticApplicative<F>): (condition: boolean, fu: HKT<void>[F]) => HKT<void>[F];

@@ -24,2 +24,8 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {

}
/** Perform a applicative action when a condition is true */
export function when(applicative) {
return function (condition, fu) {
return condition ? fu : applicative.of(undefined);
};
}
//# sourceMappingURL=Applicative.js.map

@@ -5,3 +5,3 @@ import { HKT, HKTS, HKT2, HKT2S } from './HKT';

import { StaticOrd } from './Ord';
import { Predicate, Lazy, Endomorphism } from './function';
import { Predicate, Lazy, Endomorphism, Refinement } from './function';
declare module './HKT' {

@@ -51,2 +51,3 @@ interface HKT<A> {

export declare function filter<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function refine<A>(as: Array<A>): <B extends A>(refinement: Refinement<A, B>) => Array<B>;
export declare function copy<A>(as: Array<A>): Array<A>;

@@ -53,0 +54,0 @@ export declare function unsafeInsertAt<A>(i: number, a: A, as: Array<A>): Array<A>;

@@ -112,2 +112,5 @@ import { liftA2 } from './Apply';

}
export function refine(as) {
return function (refinement) { return as.filter(refinement); };
}
export function copy(as) {

@@ -114,0 +117,0 @@ return as.slice();

@@ -79,3 +79,3 @@ import { HKT, HKTS, HKT2, HKT2S } from './HKT';

export declare function map<L, A, B>(f: (a: A) => B, fa: Either<L, A>): Either<L, B>;
export declare function of<L, A>(a: A): Right<L, A>;
export declare function of<L, A>(a: A): Either<L, A>;
export declare function ap<L, A, B>(fab: Either<L, (a: A) => B>, fa: Either<L, A>): Either<L, B>;

@@ -82,0 +82,0 @@ export declare function chain<L, A, B>(f: (a: A) => Either<L, B>, fa: Either<L, A>): Either<L, B>;

@@ -37,2 +37,3 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, L, A, B>(f: (a: A) => EitherT<M, L, B>, fa: EitherT<M, L, A>): EitherT<M, L, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
export declare function bimap<M extends HKTS>(monad: StaticMonad<M>): <L, L2, A, B>(f: (l: L) => L2, g: (a: A) => B, fa: EitherT<M, L, A>) => EitherT<M, L2, B>;

@@ -39,0 +40,0 @@ /** lifts `M<A>` to `EitherT<M, L, A>` */

@@ -50,2 +50,11 @@ import * as either from './Either';

}
export function getStaticMonad(monad) {
return {
URI: URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
export function bimap(monad) {

@@ -52,0 +61,0 @@ return function (f, g, fa) {

import { HKT, HKTS } from './HKT';
import { StaticMonoid } from './Monoid';
import { StaticApplicative } from './Applicative';
export interface StaticFoldable<F extends HKTS> {

@@ -20,1 +21,3 @@ readonly URI: F;

export declare function intercalate<F extends HKTS, M>(foldable: StaticFoldable<F>, monoid: StaticMonoid<M>): (sep: M, fm: HKT<M>[F]) => M;
export declare function traverse_<M extends HKTS, F extends HKTS>(applicative: StaticApplicative<M>, foldable: StaticFoldable<F>): <A, B>(f: (a: A) => HKT<B>[M], fa: HKT<A>[F]) => HKT<void>[M];
export declare function sequence_<M extends HKTS, F extends HKTS>(applicative: StaticApplicative<M>, foldable: StaticFoldable<F>): <A>(fa: HKT<A>[F]) => HKT<void>[M];

@@ -1,2 +0,3 @@

import { monoidArray } from './Monoid';
import { applyFirst } from './Apply';
import { identity } from './function';
export function foldMap(foldable, monoid, f, fa) {

@@ -6,3 +7,3 @@ return foldable.reduce(function (acc, x) { return monoid.concat(f(x), acc); }, monoid.empty(), fa);

export function toArray(foldable, fa) {
return foldMap(foldable, monoidArray, function (a) { return [a]; }, fa);
return foldable.reduce(function (b, a) { return b.concat([a]); }, [], fa);
}

@@ -36,2 +37,10 @@ /** returns the composition of two foldables */

}
export function traverse_(applicative, foldable) {
return function (f, fa) { return toArray(foldable, fa)
.reduce(function (mu, a) { return applyFirst(applicative)(mu, f(a)); }, applicative.of(undefined)); };
}
export function sequence_(applicative, foldable) {
var t = traverse_(applicative, foldable);
return function (fa) { return t(identity, fa); };
}
//# sourceMappingURL=Foldable.js.map

@@ -21,3 +21,7 @@ import { HKT, HKTS } from './HKT';

export declare type Predicate<A> = (a: A) => boolean;
export declare type Refinement<A, B extends A> = (a: A) => a is B;
export declare function not<A>(predicate: Predicate<A>): Predicate<A>;
export declare function or<A, B1 extends A, B2 extends A>(p1: Refinement<A, B1>, p2: Refinement<A, B2>): Refinement<A, B1 | B2>;
export declare function or<A>(p1: Predicate<A>, p2: Predicate<A>): Predicate<A>;
export declare function and<A>(p1: Predicate<A>, p2: Predicate<A>): Predicate<A>;
export declare type Endomorphism<A> = (a: A) => A;

@@ -24,0 +28,0 @@ export declare type BinaryOperation<A, B> = Function2<A, A, B>;

export function not(predicate) {
return function (a) { return !predicate(a); };
}
export function or(p1, p2) {
return function (a) { return p1(a) || p2(a); };
}
export function and(p1, p2) {
return function (a) { return p1(a) && p2(a); };
}
export function constant(a) {

@@ -5,0 +11,0 @@ return function () { return a; };

@@ -5,3 +5,6 @@ export interface HKT<A> {

}
export interface HKT3<A, B, C> {
}
export declare type HKTS = keyof HKT<any>;
export declare type HKT2S = keyof HKT2<any, any>;
export declare type HKT3S = keyof HKT3<any, any, any>;

@@ -19,1 +19,2 @@ import { StaticSemigroup } from './Semigroup';

export declare const monoidString: StaticMonoid<string>;
export declare function getFunctionStaticMonoid<M>(monoid: StaticMonoid<M>): <A>() => StaticMonoid<(a: A) => M>;
import { getProductStaticSemigroup, getDualStaticSemigroup, fold as foldSemigroup } from './Semigroup';
import { constant } from './function';
export function fold(monoid, as) {

@@ -44,2 +45,9 @@ return foldSemigroup(monoid, monoid.empty(), as);

};
export function getFunctionStaticMonoid(monoid) {
var empty = constant(constant(monoid.empty()));
return function () { return ({
empty: empty,
concat: function (f, g) { return function (a) { return monoid.concat(f(a), g(a)); }; }
}); };
}
//# sourceMappingURL=Monoid.js.map

@@ -33,4 +33,5 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, A, B>(f: (a: A) => OptionT<M, B>, fa: OptionT<M, A>): OptionT<M, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
export declare function fromOption<M extends HKTS>(monad: StaticMonad<M>): <A>(value: Option<A>) => OptionT<M, A>;
export declare const some: typeof of;
export declare function none<M extends HKTS>(monad: StaticMonad<M>): OptionT<M, any>;

@@ -47,2 +47,11 @@ import * as option from './Option';

}
export function getStaticMonad(monad) {
return {
URI: URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
export function fromOption(monad) {

@@ -49,0 +58,0 @@ return function (value) { return new OptionT(monad, monad.of(value)); };

@@ -32,2 +32,3 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, E, A, B>(f: (a: A) => ReaderT<M, E, B>, fa: ReaderT<M, E, A>): ReaderT<M, E, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
/** reads the current context */

@@ -34,0 +35,0 @@ export declare function ask<M extends HKTS, E>(monad: StaticMonad<M>): ReaderT<M, E, E>;

@@ -46,2 +46,11 @@ export var URI = 'ReaderT';

}
export function getStaticMonad(monad) {
return {
URI: URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
/** reads the current context */

@@ -48,0 +57,0 @@ export function ask(monad) {

@@ -1,2 +0,2 @@

import { HKTS } from './HKT';
import { HKT, HKTS } from './HKT';
import { StaticPointed, FantasyPointed } from './Pointed';

@@ -10,1 +10,3 @@ import { StaticApply, FantasyApply } from './Apply';

export declare function getApplicativeComposition<FG extends HKTS>(URI: FG): <F extends HKTS, G extends HKTS>(applicativeF: StaticApplicative<F>, applicativeG: StaticApplicative<G>) => StaticApplicative<FG>;
/** Perform a applicative action when a condition is true */
export declare function when<F extends HKTS>(applicative: StaticApplicative<F>): (condition: boolean, fu: HKT<void>[F]) => HKT<void>[F];

@@ -27,2 +27,9 @@ "use strict";

exports.getApplicativeComposition = getApplicativeComposition;
/** Perform a applicative action when a condition is true */
function when(applicative) {
return function (condition, fu) {
return condition ? fu : applicative.of(undefined);
};
}
exports.when = when;
//# sourceMappingURL=Applicative.js.map

@@ -5,3 +5,3 @@ import { HKT, HKTS, HKT2, HKT2S } from './HKT';

import { StaticOrd } from './Ord';
import { Predicate, Lazy, Endomorphism } from './function';
import { Predicate, Lazy, Endomorphism, Refinement } from './function';
declare module './HKT' {

@@ -51,2 +51,3 @@ interface HKT<A> {

export declare function filter<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function refine<A>(as: Array<A>): <B extends A>(refinement: Refinement<A, B>) => Array<B>;
export declare function copy<A>(as: Array<A>): Array<A>;

@@ -53,0 +54,0 @@ export declare function unsafeInsertAt<A>(i: number, a: A, as: Array<A>): Array<A>;

@@ -140,2 +140,6 @@ "use strict";

exports.filter = filter;
function refine(as) {
return function (refinement) { return as.filter(refinement); };
}
exports.refine = refine;
function copy(as) {

@@ -142,0 +146,0 @@ return as.slice();

@@ -79,3 +79,3 @@ import { HKT, HKTS, HKT2, HKT2S } from './HKT';

export declare function map<L, A, B>(f: (a: A) => B, fa: Either<L, A>): Either<L, B>;
export declare function of<L, A>(a: A): Right<L, A>;
export declare function of<L, A>(a: A): Either<L, A>;
export declare function ap<L, A, B>(fab: Either<L, (a: A) => B>, fa: Either<L, A>): Either<L, B>;

@@ -82,0 +82,0 @@ export declare function chain<L, A, B>(f: (a: A) => Either<L, B>, fa: Either<L, A>): Either<L, B>;

@@ -37,2 +37,3 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, L, A, B>(f: (a: A) => EitherT<M, L, B>, fa: EitherT<M, L, A>): EitherT<M, L, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
export declare function bimap<M extends HKTS>(monad: StaticMonad<M>): <L, L2, A, B>(f: (l: L) => L2, g: (a: A) => B, fa: EitherT<M, L, A>) => EitherT<M, L2, B>;

@@ -39,0 +40,0 @@ /** lifts `M<A>` to `EitherT<M, L, A>` */

@@ -58,2 +58,12 @@ "use strict";

exports.chain = chain;
function getStaticMonad(monad) {
return {
URI: exports.URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
exports.getStaticMonad = getStaticMonad;
function bimap(monad) {

@@ -60,0 +70,0 @@ return function (f, g, fa) {

import { HKT, HKTS } from './HKT';
import { StaticMonoid } from './Monoid';
import { StaticApplicative } from './Applicative';
export interface StaticFoldable<F extends HKTS> {

@@ -20,1 +21,3 @@ readonly URI: F;

export declare function intercalate<F extends HKTS, M>(foldable: StaticFoldable<F>, monoid: StaticMonoid<M>): (sep: M, fm: HKT<M>[F]) => M;
export declare function traverse_<M extends HKTS, F extends HKTS>(applicative: StaticApplicative<M>, foldable: StaticFoldable<F>): <A, B>(f: (a: A) => HKT<B>[M], fa: HKT<A>[F]) => HKT<void>[M];
export declare function sequence_<M extends HKTS, F extends HKTS>(applicative: StaticApplicative<M>, foldable: StaticFoldable<F>): <A>(fa: HKT<A>[F]) => HKT<void>[M];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Monoid_1 = require("./Monoid");
var Apply_1 = require("./Apply");
var function_1 = require("./function");
function foldMap(foldable, monoid, f, fa) {

@@ -9,3 +10,3 @@ return foldable.reduce(function (acc, x) { return monoid.concat(f(x), acc); }, monoid.empty(), fa);

function toArray(foldable, fa) {
return foldMap(foldable, Monoid_1.monoidArray, function (a) { return [a]; }, fa);
return foldable.reduce(function (b, a) { return b.concat([a]); }, [], fa);
}

@@ -42,2 +43,12 @@ exports.toArray = toArray;

exports.intercalate = intercalate;
function traverse_(applicative, foldable) {
return function (f, fa) { return toArray(foldable, fa)
.reduce(function (mu, a) { return Apply_1.applyFirst(applicative)(mu, f(a)); }, applicative.of(undefined)); };
}
exports.traverse_ = traverse_;
function sequence_(applicative, foldable) {
var t = traverse_(applicative, foldable);
return function (fa) { return t(function_1.identity, fa); };
}
exports.sequence_ = sequence_;
//# sourceMappingURL=Foldable.js.map

@@ -21,3 +21,7 @@ import { HKT, HKTS } from './HKT';

export declare type Predicate<A> = (a: A) => boolean;
export declare type Refinement<A, B extends A> = (a: A) => a is B;
export declare function not<A>(predicate: Predicate<A>): Predicate<A>;
export declare function or<A, B1 extends A, B2 extends A>(p1: Refinement<A, B1>, p2: Refinement<A, B2>): Refinement<A, B1 | B2>;
export declare function or<A>(p1: Predicate<A>, p2: Predicate<A>): Predicate<A>;
export declare function and<A>(p1: Predicate<A>, p2: Predicate<A>): Predicate<A>;
export declare type Endomorphism<A> = (a: A) => A;

@@ -24,0 +28,0 @@ export declare type BinaryOperation<A, B> = Function2<A, A, B>;

@@ -7,2 +7,10 @@ "use strict";

exports.not = not;
function or(p1, p2) {
return function (a) { return p1(a) || p2(a); };
}
exports.or = or;
function and(p1, p2) {
return function (a) { return p1(a) && p2(a); };
}
exports.and = and;
function constant(a) {

@@ -9,0 +17,0 @@ return function () { return a; };

@@ -5,3 +5,6 @@ export interface HKT<A> {

}
export interface HKT3<A, B, C> {
}
export declare type HKTS = keyof HKT<any>;
export declare type HKT2S = keyof HKT2<any, any>;
export declare type HKT3S = keyof HKT3<any, any, any>;

@@ -19,1 +19,2 @@ import { StaticSemigroup } from './Semigroup';

export declare const monoidString: StaticMonoid<string>;
export declare function getFunctionStaticMonoid<M>(monoid: StaticMonoid<M>): <A>() => StaticMonoid<(a: A) => M>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Semigroup_1 = require("./Semigroup");
var function_1 = require("./function");
function fold(monoid, as) {

@@ -49,2 +50,10 @@ return Semigroup_1.fold(monoid, monoid.empty(), as);

};
function getFunctionStaticMonoid(monoid) {
var empty = function_1.constant(function_1.constant(monoid.empty()));
return function () { return ({
empty: empty,
concat: function (f, g) { return function (a) { return monoid.concat(f(a), g(a)); }; }
}); };
}
exports.getFunctionStaticMonoid = getFunctionStaticMonoid;
//# sourceMappingURL=Monoid.js.map

@@ -33,4 +33,5 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, A, B>(f: (a: A) => OptionT<M, B>, fa: OptionT<M, A>): OptionT<M, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
export declare function fromOption<M extends HKTS>(monad: StaticMonad<M>): <A>(value: Option<A>) => OptionT<M, A>;
export declare const some: typeof of;
export declare function none<M extends HKTS>(monad: StaticMonad<M>): OptionT<M, any>;

@@ -55,2 +55,12 @@ "use strict";

exports.chain = chain;
function getStaticMonad(monad) {
return {
URI: exports.URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
exports.getStaticMonad = getStaticMonad;
function fromOption(monad) {

@@ -57,0 +67,0 @@ return function (value) { return new OptionT(monad, monad.of(value)); };

@@ -32,2 +32,3 @@ import { HKT, HKTS } from './HKT';

export declare function chain<M extends HKTS, E, A, B>(f: (a: A) => ReaderT<M, E, B>, fa: ReaderT<M, E, A>): ReaderT<M, E, B>;
export declare function getStaticMonad<M extends HKTS>(monad: StaticMonad<M>): StaticMonad<URI>;
/** reads the current context */

@@ -34,0 +35,0 @@ export declare function ask<M extends HKTS, E>(monad: StaticMonad<M>): ReaderT<M, E, E>;

@@ -54,2 +54,12 @@ "use strict";

exports.chain = chain;
function getStaticMonad(monad) {
return {
URI: exports.URI,
of: of(monad),
map: map,
ap: ap,
chain: chain
};
}
exports.getStaticMonad = getStaticMonad;
/** reads the current context */

@@ -56,0 +66,0 @@ function ask(monad) {

{
"name": "fp-ts",
"version": "0.2.7",
"version": "0.2.8",
"description": "Functional programming in TypeScript",

@@ -5,0 +5,0 @@ "files": [

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc