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.0.2 to 0.0.3

lib-jsnext/dictionary.d.ts

13

CHANGELOG.md

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

# 0.0.3
- **New Feature**
- make Array<T> a HKT and deprecate `to`,`from` helper functions, fix #5 (@gcanti)
- add `Traced` comonad (@bumbleblym)
- add `getOrElse` method to `Option` (@gcanti)
- add NonEmptyArray, fix #12 (@gcanti)
- **Polish**
- add tslint
- **Bug Fix**
- fix `State` definition (@gcanti)
# 0.0.2

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

101

lib-jsnext/Arr.d.ts

@@ -5,48 +5,59 @@ import { HKT } from './HKT';

import { Ord } from './Ord';
import { Predicate, Lazy, Function1, Function2, Endomorphism } from './function';
import { Predicate, identity, Lazy, Function1, Function2, Endomorphism } from './function';
export declare type URI = 'Arr';
export declare type Arr<A> = HKT<URI, A>;
export declare function to<A>(x: Array<A>): Arr<A>;
export declare function from<A>(x: Arr<A>): Array<A>;
export declare const empty: Lazy<Arr<any>>;
export declare function concat<A>(x: Arr<A>, y: Arr<A>): Arr<A>;
export declare function map<A, B>(f: Function1<A, B>, fa: Arr<A>): Arr<B>;
export declare function of<A>(a: A): Arr<A>;
export declare function ap<A, B>(fab: Arr<Function1<A, B>>, fa: Arr<A>): Arr<B>;
export declare function chain<A, B>(f: Function1<A, Arr<B>>, fa: Arr<A>): Arr<B>;
export declare function reduce<A, B>(f: Function2<B, A, B>, b: B, fa: Arr<A>): B;
export declare function traverse<F, A, B>(applicative: Applicative<F>, f: Function1<A, HKT<F, B>>, ta: Arr<A>): HKT<F, Arr<B>>;
export declare const zero: Lazy<HKT<"Arr", any>>;
declare global {
interface Array<T> {
__hkt: URI;
__hkta: T;
}
}
/** Deprecated. Use a raw array instead
* @deprecated
*/
export declare const to: typeof identity;
/** Deprecated. Use a raw array instead
* @deprecated
*/
export declare const from: typeof identity;
export declare const empty: Lazy<Array<any>>;
export declare function concat<A>(x: Array<A>, y: Array<A>): Array<A>;
export declare function map<A, B>(f: Function1<A, B>, fa: Array<A>): Array<B>;
export declare function of<A>(a: A): Array<A>;
export declare function ap<A, B>(fab: Array<Function1<A, B>>, fa: Array<A>): Array<B>;
export declare function chain<A, B>(f: Function1<A, Array<B>>, fa: Array<A>): Array<B>;
export declare function reduce<A, B>(f: Function2<B, A, B>, b: B, fa: Array<A>): B;
export declare const curriedSnoc: (a: {}) => (b: {}) => {}[];
export declare function traverse<F, A, B>(applicative: Applicative<F>, f: Function1<A, HKT<F, B>>, ta: Array<A>): HKT<F, Array<B>>;
export declare const zero: Lazy<any[]>;
export declare const alt: typeof concat;
export declare function unfoldr<A, B>(f: Function1<B, HKTOption<[A, B]>>, b: B): Arr<A>;
export declare function fold<A, B>(nil: Lazy<B>, cons: (head: A, tail: Arr<A>) => B, as: Arr<A>): B;
export declare function length<A>(as: Arr<A>): number;
export declare function isEmpty<A>(as: Arr<A>): boolean;
export declare function isOutOfBound<A>(i: number, as: Arr<A>): boolean;
export declare function index<A>(as: Arr<A>, i: number): Option<A>;
export declare function cons<A>(a: A, as: Arr<A>): Arr<A>;
export declare function snoc<A>(as: Arr<A>, a: A): Arr<A>;
export declare const curriedSnoc: (a: {}) => (b: {}) => HKT<"Arr", {}>;
export declare function head<A>(as: Arr<A>): Option<A>;
export declare function last<A>(as: Arr<A>): Option<A>;
export declare function tail<A>(as: Arr<A>): Option<Arr<A>>;
export declare function slice<A>(start: number, end: number, as: Arr<A>): Arr<A>;
export declare function init<A>(as: Arr<A>): Option<Arr<A>>;
export declare function take<A>(n: number, as: Arr<A>): Arr<A>;
export declare function takeWhile<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function drop<A>(n: number, as: Arr<A>): Arr<A>;
export declare function dropWhile<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function findIndex<A>(predicate: Predicate<A>, as: Arr<A>): Option<number>;
export declare function filter<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function copy<A>(as: Arr<A>): Array<A>;
export declare function unsafeInsertAt<A>(i: number, a: A, as: Arr<A>): Arr<A>;
export declare function insertAt<A>(i: number, a: A, as: Arr<A>): Option<Arr<A>>;
export declare function unsafeUpdateAt<A>(i: number, a: A, as: Arr<A>): Arr<A>;
export declare function updateAt<A>(i: number, a: A, as: Arr<A>): Option<Arr<A>>;
export declare function unsafeDeleteAt<A>(i: number, as: Arr<A>): Arr<A>;
export declare function deleteAt<A>(i: number, as: Arr<A>): Option<Arr<A>>;
export declare function modifyAt<A>(i: number, f: Endomorphism<A>, as: Arr<A>): Option<Arr<A>>;
export declare function reverse<A>(as: Arr<A>): Arr<A>;
export declare function mapOption<A, B>(f: Function1<A, HKTOption<B>>, as: Arr<A>): Arr<B>;
export declare function catOptions<A>(as: Arr<HKTOption<A>>): Arr<A>;
export declare function sort<A>(ord: Ord<A>, as: Arr<A>): Arr<A>;
export declare function unfoldr<A, B>(f: Function1<B, HKTOption<[A, B]>>, b: B): Array<A>;
export declare function fold<A, B>(nil: Lazy<B>, cons: (head: A, tail: Array<A>) => B, as: Array<A>): B;
export declare function length<A>(as: Array<A>): number;
export declare function isEmpty<A>(as: Array<A>): boolean;
export declare function isOutOfBound<A>(i: number, as: Array<A>): boolean;
export declare function index<A>(as: Array<A>, i: number): Option<A>;
export declare function cons<A>(a: A, as: Array<A>): Array<A>;
export declare function snoc<A>(as: Array<A>, a: A): Array<A>;
export declare function head<A>(as: Array<A>): Option<A>;
export declare function last<A>(as: Array<A>): Option<A>;
export declare function tail<A>(as: Array<A>): Option<Array<A>>;
export declare function slice<A>(start: number, end: number, as: Array<A>): Array<A>;
export declare function init<A>(as: Array<A>): Option<Array<A>>;
export declare function take<A>(n: number, as: Array<A>): Array<A>;
export declare function takeWhile<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function drop<A>(n: number, as: Array<A>): Array<A>;
export declare function dropWhile<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function findIndex<A>(predicate: Predicate<A>, as: Array<A>): Option<number>;
export declare function filter<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function copy<A>(as: Array<A>): Array<A>;
export declare function unsafeInsertAt<A>(i: number, a: A, as: Array<A>): Array<A>;
export declare function insertAt<A>(i: number, a: A, as: Array<A>): Option<Array<A>>;
export declare function unsafeUpdateAt<A>(i: number, a: A, as: Array<A>): Array<A>;
export declare function updateAt<A>(i: number, a: A, as: Array<A>): Option<Array<A>>;
export declare function unsafeDeleteAt<A>(i: number, as: Array<A>): Array<A>;
export declare function deleteAt<A>(i: number, as: Array<A>): Option<Array<A>>;
export declare function modifyAt<A>(i: number, f: Endomorphism<A>, as: Array<A>): Option<Array<A>>;
export declare function reverse<A>(as: Array<A>): Array<A>;
export declare function mapOption<A, B>(f: Function1<A, HKTOption<B>>, as: Array<A>): Array<B>;
export declare function catOptions<A>(as: Array<HKTOption<A>>): Array<A>;
export declare function sort<A>(ord: Ord<A>, as: Array<A>): Array<A>;

@@ -5,28 +5,32 @@ import { liftA2 } from './Apply';

import { identity, constant, curry } from './function';
export function to(x) {
return x;
}
export function from(x) {
return x;
}
export var empty = constant(to([]));
// TODO(v0.1) remove
/** Deprecated. Use a raw array instead
* @deprecated
*/
export var to = identity;
// TODO(v0.1) remove
/** Deprecated. Use a raw array instead
* @deprecated
*/
export var from = identity;
export var empty = constant([]);
export function concat(x, y) {
return to(from(x).concat(from(y)));
return x.concat(y);
}
export function map(f, fa) {
return to(from(fa).map(f));
return fa.map(f);
}
export function of(a) {
return to([a]);
return [a];
}
export function ap(fab, fa) {
var a = from(fa);
return to(from(fab).reduce(function (acc, f) { return acc.concat(a.map(f)); }, []));
return fab.reduce(function (acc, f) { return acc.concat(fa.map(f)); }, []);
}
export function chain(f, fa) {
return to(from(fa).reduce(function (acc, a) { return acc.concat(from(f(a))); }, []));
return fa.reduce(function (acc, a) { return acc.concat(f(a)); }, []);
}
export function reduce(f, b, fa) {
return from(fa).reduce(f, b);
return fa.reduce(f, b);
}
export var curriedSnoc = curry(snoc);
export function traverse(applicative, f, ta) {

@@ -52,10 +56,9 @@ var snocA2 = liftA2(applicative, curriedSnoc);

}
return to(ret);
return ret;
}
export function fold(nil, cons, as) {
var xs = from(as);
return xs.length === 0 ? nil() : cons(xs[0], to(xs.slice(1)));
return as.length === 0 ? nil() : cons(as[0], as.slice(1));
}
export function length(as) {
return from(as).length;
return as.length;
}

@@ -66,17 +69,15 @@ export function isEmpty(as) {

export function isOutOfBound(i, as) {
return i < 0 || i >= from(as).length;
return i < 0 || i >= as.length;
}
export function index(as, i) {
var xs = from(as);
return isOutOfBound(i, as) ? option.none : option.some(xs[i]);
return isOutOfBound(i, as) ? option.none : option.some(as[i]);
}
export function cons(a, as) {
return to([a].concat(from(as)));
return [a].concat(as);
}
export function snoc(as, a) {
return to(from(as).concat(a));
return as.concat(a);
}
export var curriedSnoc = curry(snoc);
export function head(as) {
return isEmpty(as) ? option.none : option.some(from(as)[0]);
return isEmpty(as) ? option.none : option.some(as[0]);
}

@@ -87,13 +88,11 @@ export function last(as) {

export function tail(as) {
var xs = from(as);
var len = xs.length;
return len === 0 ? option.none : option.some(to(xs.slice(1)));
var len = as.length;
return len === 0 ? option.none : option.some(as.slice(1));
}
export function slice(start, end, as) {
return to(from(as).slice(start, end));
return as.slice(start, end);
}
export function init(as) {
var xs = from(as);
var len = xs.length;
return len === 0 ? option.none : option.some(to(xs.slice(0, len - 1)));
var len = as.length;
return len === 0 ? option.none : option.some(as.slice(0, len - 1));
}

@@ -104,3 +103,3 @@ export function take(n, as) {

export function takeWhile(predicate, as) {
return to(from(as).slice().filter(predicate));
return as.slice().filter(predicate);
}

@@ -114,5 +113,5 @@ export function drop(n, as) {

export function findIndex(predicate, as) {
var xs = from(as);
for (var i = 0, len = xs.length; i < len; i++) {
if (predicate(xs[i])) {
var len = as.length;
for (var i = 0; i < len; i++) {
if (predicate(as[i])) {
return option.some(i);

@@ -124,6 +123,6 @@ }

export function filter(predicate, as) {
return to(from(as).filter(predicate));
return as.filter(predicate);
}
export function copy(as) {
return from(as).slice();
return as.slice();
}

@@ -133,6 +132,6 @@ export function unsafeInsertAt(i, a, as) {

xs.splice(i, 0, a);
return to(xs);
return xs;
}
export function insertAt(i, a, as) {
return i < 0 || i > from(as).length ? option.none : option.some(unsafeInsertAt(i, a, as));
return i < 0 || i > as.length ? option.none : option.some(unsafeInsertAt(i, a, as));
}

@@ -142,3 +141,3 @@ export function unsafeUpdateAt(i, a, as) {

xs[i] = a;
return to(xs);
return xs;
}

@@ -151,3 +150,3 @@ export function updateAt(i, a, as) {

xs.splice(i, 1);
return to(xs);
return xs;
}

@@ -158,6 +157,6 @@ export function deleteAt(i, as) {

export function modifyAt(i, f, as) {
return isOutOfBound(i, as) ? option.none : updateAt(i, f(from(as)[i]), as);
return isOutOfBound(i, as) ? option.none : updateAt(i, f(as[i]), as);
}
export function reverse(as) {
return to(copy(as).reverse());
return copy(as).reverse();
}

@@ -171,6 +170,7 @@ export function mapOption(f, as) {

export function sort(ord, as) {
return to(copy(as).sort(toNativeComparator(ord.compare)));
return copy(as).sort(toNativeComparator(ord.compare));
}
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, zero: zero, alt: alt });
({ empty: empty, concat: concat, map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, zero: zero, alt: alt });
//# sourceMappingURL=Arr.js.map

@@ -49,4 +49,5 @@ import { identity } from './function';

}
// tslint:disable-next-line no-unused-expression
;
({ map: map, contramap: contramap });
//# sourceMappingURL=Const.js.map

@@ -21,5 +21,5 @@ import { HKT } from './HKT';

value: L;
static of: typeof of;
__hkt: HKT<URI, L>;
__hkta: A;
static of: typeof of;
constructor(value: L);

@@ -41,5 +41,5 @@ map<B>(f: Function1<A, B>): Either<L, B>;

value: A;
static of: typeof of;
__hkt: HKT<URI, L>;
__hkta: A;
static of: typeof of;
constructor(value: A);

@@ -46,0 +46,0 @@ map<B>(f: Function1<A, B>): Either<L, B>;

@@ -9,6 +9,6 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
static extract: typeof extract;
__hkt: URI;
__hkta: A;
static of: typeof of;
static extract: typeof extract;
constructor(value: A);

@@ -15,0 +15,0 @@ map<B>(f: Function1<A, B>): Identity<B>;

@@ -76,4 +76,5 @@ var Identity = (function () {

}
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, alt: alt, extract: extract, extend: extend });
//# sourceMappingURL=Identity.js.map

@@ -9,5 +9,5 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
__hkt: URI;
__hkta: A;
static of: typeof of;
constructor(value: Lazy<A>);

@@ -14,0 +14,0 @@ run(): A;

@@ -51,4 +51,5 @@ import { constant } from './function';

}
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=IO.js.map

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

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -23,7 +24,7 @@ equals(setoid: Setoid<A>, fy: Option<A>): boolean;

export declare class None<A> implements Option<A> {
__hkt: URI;
__hkta: A;
static of: typeof of;
static zero: typeof zero;
static value: Option<any>;
__hkt: URI;
__hkta: A;
constructor();

@@ -38,2 +39,3 @@ map<B>(f: Function1<A, B>): Option<B>;

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -48,6 +50,6 @@ equals(setoid: Setoid<A>, fy: Option<A>): boolean;

value: A;
static of: typeof of;
static zero: typeof zero;
__hkt: URI;
__hkta: A;
static of: typeof of;
static zero: typeof zero;
constructor(value: A);

@@ -62,2 +64,3 @@ map<B>(f: Function1<A, B>): Option<B>;

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -64,0 +67,0 @@ equals(setoid: Setoid<any>, fy: Option<any>): boolean;

@@ -32,2 +32,5 @@ import { identity, constant, constFalse, constTrue } from './function';

};
None.prototype.getOrElse = function (f) {
return f();
};
None.prototype.concat = function (semigroup, fy) {

@@ -84,2 +87,5 @@ return fy;

};
Some.prototype.getOrElse = function (f) {
return this.value;
};
Some.prototype.concat = function (semigroup, fy) {

@@ -86,0 +92,0 @@ var _this = this;

@@ -7,5 +7,5 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
__hkt: HKT<URI, E>;
__hkta: A;
static of: typeof of;
constructor(value: Function1<E, A>);

@@ -12,0 +12,0 @@ run(e: E): A;

@@ -49,4 +49,5 @@ import { identity } from './function';

}
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=Reader.js.map

@@ -16,3 +16,6 @@ var State = (function () {

var _this = this;
return new State(function (s) { return [f(_this.eval(s)), s]; });
return new State(function (s) {
var _a = _this.run(s), a = _a[0], s1 = _a[1];
return [f(a), s1];
});
};

@@ -25,3 +28,6 @@ State.prototype.ap = function (fab) {

var _this = this;
return new State(function (s) { return (f(_this.eval(s))).run(s); });
return new State(function (s) {
var _a = _this.run(s), a = _a[0], s1 = _a[1];
return f(a).run(s1);
});
};

@@ -53,6 +59,7 @@ return State;

export function gets(f) {
return get().chain(function (s) { return of(f(s)); });
return new State(function (s) { return [f(s), s]; });
}
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=State.js.map

@@ -5,48 +5,59 @@ import { HKT } from './HKT';

import { Ord } from './Ord';
import { Predicate, Lazy, Function1, Function2, Endomorphism } from './function';
import { Predicate, identity, Lazy, Function1, Function2, Endomorphism } from './function';
export declare type URI = 'Arr';
export declare type Arr<A> = HKT<URI, A>;
export declare function to<A>(x: Array<A>): Arr<A>;
export declare function from<A>(x: Arr<A>): Array<A>;
export declare const empty: Lazy<Arr<any>>;
export declare function concat<A>(x: Arr<A>, y: Arr<A>): Arr<A>;
export declare function map<A, B>(f: Function1<A, B>, fa: Arr<A>): Arr<B>;
export declare function of<A>(a: A): Arr<A>;
export declare function ap<A, B>(fab: Arr<Function1<A, B>>, fa: Arr<A>): Arr<B>;
export declare function chain<A, B>(f: Function1<A, Arr<B>>, fa: Arr<A>): Arr<B>;
export declare function reduce<A, B>(f: Function2<B, A, B>, b: B, fa: Arr<A>): B;
export declare function traverse<F, A, B>(applicative: Applicative<F>, f: Function1<A, HKT<F, B>>, ta: Arr<A>): HKT<F, Arr<B>>;
export declare const zero: Lazy<HKT<"Arr", any>>;
declare global {
interface Array<T> {
__hkt: URI;
__hkta: T;
}
}
/** Deprecated. Use a raw array instead
* @deprecated
*/
export declare const to: typeof identity;
/** Deprecated. Use a raw array instead
* @deprecated
*/
export declare const from: typeof identity;
export declare const empty: Lazy<Array<any>>;
export declare function concat<A>(x: Array<A>, y: Array<A>): Array<A>;
export declare function map<A, B>(f: Function1<A, B>, fa: Array<A>): Array<B>;
export declare function of<A>(a: A): Array<A>;
export declare function ap<A, B>(fab: Array<Function1<A, B>>, fa: Array<A>): Array<B>;
export declare function chain<A, B>(f: Function1<A, Array<B>>, fa: Array<A>): Array<B>;
export declare function reduce<A, B>(f: Function2<B, A, B>, b: B, fa: Array<A>): B;
export declare const curriedSnoc: (a: {}) => (b: {}) => {}[];
export declare function traverse<F, A, B>(applicative: Applicative<F>, f: Function1<A, HKT<F, B>>, ta: Array<A>): HKT<F, Array<B>>;
export declare const zero: Lazy<any[]>;
export declare const alt: typeof concat;
export declare function unfoldr<A, B>(f: Function1<B, HKTOption<[A, B]>>, b: B): Arr<A>;
export declare function fold<A, B>(nil: Lazy<B>, cons: (head: A, tail: Arr<A>) => B, as: Arr<A>): B;
export declare function length<A>(as: Arr<A>): number;
export declare function isEmpty<A>(as: Arr<A>): boolean;
export declare function isOutOfBound<A>(i: number, as: Arr<A>): boolean;
export declare function index<A>(as: Arr<A>, i: number): Option<A>;
export declare function cons<A>(a: A, as: Arr<A>): Arr<A>;
export declare function snoc<A>(as: Arr<A>, a: A): Arr<A>;
export declare const curriedSnoc: (a: {}) => (b: {}) => HKT<"Arr", {}>;
export declare function head<A>(as: Arr<A>): Option<A>;
export declare function last<A>(as: Arr<A>): Option<A>;
export declare function tail<A>(as: Arr<A>): Option<Arr<A>>;
export declare function slice<A>(start: number, end: number, as: Arr<A>): Arr<A>;
export declare function init<A>(as: Arr<A>): Option<Arr<A>>;
export declare function take<A>(n: number, as: Arr<A>): Arr<A>;
export declare function takeWhile<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function drop<A>(n: number, as: Arr<A>): Arr<A>;
export declare function dropWhile<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function findIndex<A>(predicate: Predicate<A>, as: Arr<A>): Option<number>;
export declare function filter<A>(predicate: Predicate<A>, as: Arr<A>): Arr<A>;
export declare function copy<A>(as: Arr<A>): Array<A>;
export declare function unsafeInsertAt<A>(i: number, a: A, as: Arr<A>): Arr<A>;
export declare function insertAt<A>(i: number, a: A, as: Arr<A>): Option<Arr<A>>;
export declare function unsafeUpdateAt<A>(i: number, a: A, as: Arr<A>): Arr<A>;
export declare function updateAt<A>(i: number, a: A, as: Arr<A>): Option<Arr<A>>;
export declare function unsafeDeleteAt<A>(i: number, as: Arr<A>): Arr<A>;
export declare function deleteAt<A>(i: number, as: Arr<A>): Option<Arr<A>>;
export declare function modifyAt<A>(i: number, f: Endomorphism<A>, as: Arr<A>): Option<Arr<A>>;
export declare function reverse<A>(as: Arr<A>): Arr<A>;
export declare function mapOption<A, B>(f: Function1<A, HKTOption<B>>, as: Arr<A>): Arr<B>;
export declare function catOptions<A>(as: Arr<HKTOption<A>>): Arr<A>;
export declare function sort<A>(ord: Ord<A>, as: Arr<A>): Arr<A>;
export declare function unfoldr<A, B>(f: Function1<B, HKTOption<[A, B]>>, b: B): Array<A>;
export declare function fold<A, B>(nil: Lazy<B>, cons: (head: A, tail: Array<A>) => B, as: Array<A>): B;
export declare function length<A>(as: Array<A>): number;
export declare function isEmpty<A>(as: Array<A>): boolean;
export declare function isOutOfBound<A>(i: number, as: Array<A>): boolean;
export declare function index<A>(as: Array<A>, i: number): Option<A>;
export declare function cons<A>(a: A, as: Array<A>): Array<A>;
export declare function snoc<A>(as: Array<A>, a: A): Array<A>;
export declare function head<A>(as: Array<A>): Option<A>;
export declare function last<A>(as: Array<A>): Option<A>;
export declare function tail<A>(as: Array<A>): Option<Array<A>>;
export declare function slice<A>(start: number, end: number, as: Array<A>): Array<A>;
export declare function init<A>(as: Array<A>): Option<Array<A>>;
export declare function take<A>(n: number, as: Array<A>): Array<A>;
export declare function takeWhile<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function drop<A>(n: number, as: Array<A>): Array<A>;
export declare function dropWhile<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function findIndex<A>(predicate: Predicate<A>, as: Array<A>): Option<number>;
export declare function filter<A>(predicate: Predicate<A>, as: Array<A>): Array<A>;
export declare function copy<A>(as: Array<A>): Array<A>;
export declare function unsafeInsertAt<A>(i: number, a: A, as: Array<A>): Array<A>;
export declare function insertAt<A>(i: number, a: A, as: Array<A>): Option<Array<A>>;
export declare function unsafeUpdateAt<A>(i: number, a: A, as: Array<A>): Array<A>;
export declare function updateAt<A>(i: number, a: A, as: Array<A>): Option<Array<A>>;
export declare function unsafeDeleteAt<A>(i: number, as: Array<A>): Array<A>;
export declare function deleteAt<A>(i: number, as: Array<A>): Option<Array<A>>;
export declare function modifyAt<A>(i: number, f: Endomorphism<A>, as: Array<A>): Option<Array<A>>;
export declare function reverse<A>(as: Array<A>): Array<A>;
export declare function mapOption<A, B>(f: Function1<A, HKTOption<B>>, as: Array<A>): Array<B>;
export declare function catOptions<A>(as: Array<HKTOption<A>>): Array<A>;
export declare function sort<A>(ord: Ord<A>, as: Array<A>): Array<A>;

@@ -6,36 +6,38 @@ "use strict";

var function_1 = require("./function");
function to(x) {
return x;
}
exports.to = to;
function from(x) {
return x;
}
exports.from = from;
exports.empty = function_1.constant(to([]));
// TODO(v0.1) remove
/** Deprecated. Use a raw array instead
* @deprecated
*/
exports.to = function_1.identity;
// TODO(v0.1) remove
/** Deprecated. Use a raw array instead
* @deprecated
*/
exports.from = function_1.identity;
exports.empty = function_1.constant([]);
function concat(x, y) {
return to(from(x).concat(from(y)));
return x.concat(y);
}
exports.concat = concat;
function map(f, fa) {
return to(from(fa).map(f));
return fa.map(f);
}
exports.map = map;
function of(a) {
return to([a]);
return [a];
}
exports.of = of;
function ap(fab, fa) {
var a = from(fa);
return to(from(fab).reduce(function (acc, f) { return acc.concat(a.map(f)); }, []));
return fab.reduce(function (acc, f) { return acc.concat(fa.map(f)); }, []);
}
exports.ap = ap;
function chain(f, fa) {
return to(from(fa).reduce(function (acc, a) { return acc.concat(from(f(a))); }, []));
return fa.reduce(function (acc, a) { return acc.concat(f(a)); }, []);
}
exports.chain = chain;
function reduce(f, b, fa) {
return from(fa).reduce(f, b);
return fa.reduce(f, b);
}
exports.reduce = reduce;
exports.curriedSnoc = function_1.curry(snoc);
function traverse(applicative, f, ta) {

@@ -62,12 +64,11 @@ var snocA2 = Apply_1.liftA2(applicative, exports.curriedSnoc);

}
return to(ret);
return ret;
}
exports.unfoldr = unfoldr;
function fold(nil, cons, as) {
var xs = from(as);
return xs.length === 0 ? nil() : cons(xs[0], to(xs.slice(1)));
return as.length === 0 ? nil() : cons(as[0], as.slice(1));
}
exports.fold = fold;
function length(as) {
return from(as).length;
return as.length;
}

@@ -80,21 +81,19 @@ exports.length = length;

function isOutOfBound(i, as) {
return i < 0 || i >= from(as).length;
return i < 0 || i >= as.length;
}
exports.isOutOfBound = isOutOfBound;
function index(as, i) {
var xs = from(as);
return isOutOfBound(i, as) ? option.none : option.some(xs[i]);
return isOutOfBound(i, as) ? option.none : option.some(as[i]);
}
exports.index = index;
function cons(a, as) {
return to([a].concat(from(as)));
return [a].concat(as);
}
exports.cons = cons;
function snoc(as, a) {
return to(from(as).concat(a));
return as.concat(a);
}
exports.snoc = snoc;
exports.curriedSnoc = function_1.curry(snoc);
function head(as) {
return isEmpty(as) ? option.none : option.some(from(as)[0]);
return isEmpty(as) ? option.none : option.some(as[0]);
}

@@ -107,15 +106,13 @@ exports.head = head;

function tail(as) {
var xs = from(as);
var len = xs.length;
return len === 0 ? option.none : option.some(to(xs.slice(1)));
var len = as.length;
return len === 0 ? option.none : option.some(as.slice(1));
}
exports.tail = tail;
function slice(start, end, as) {
return to(from(as).slice(start, end));
return as.slice(start, end);
}
exports.slice = slice;
function init(as) {
var xs = from(as);
var len = xs.length;
return len === 0 ? option.none : option.some(to(xs.slice(0, len - 1)));
var len = as.length;
return len === 0 ? option.none : option.some(as.slice(0, len - 1));
}

@@ -128,3 +125,3 @@ exports.init = init;

function takeWhile(predicate, as) {
return to(from(as).slice().filter(predicate));
return as.slice().filter(predicate);
}

@@ -141,5 +138,5 @@ exports.takeWhile = takeWhile;

function findIndex(predicate, as) {
var xs = from(as);
for (var i = 0, len = xs.length; i < len; i++) {
if (predicate(xs[i])) {
var len = as.length;
for (var i = 0; i < len; i++) {
if (predicate(as[i])) {
return option.some(i);

@@ -152,7 +149,7 @@ }

function filter(predicate, as) {
return to(from(as).filter(predicate));
return as.filter(predicate);
}
exports.filter = filter;
function copy(as) {
return from(as).slice();
return as.slice();
}

@@ -163,7 +160,7 @@ exports.copy = copy;

xs.splice(i, 0, a);
return to(xs);
return xs;
}
exports.unsafeInsertAt = unsafeInsertAt;
function insertAt(i, a, as) {
return i < 0 || i > from(as).length ? option.none : option.some(unsafeInsertAt(i, a, as));
return i < 0 || i > as.length ? option.none : option.some(unsafeInsertAt(i, a, as));
}

@@ -174,3 +171,3 @@ exports.insertAt = insertAt;

xs[i] = a;
return to(xs);
return xs;
}

@@ -185,3 +182,3 @@ exports.unsafeUpdateAt = unsafeUpdateAt;

xs.splice(i, 1);
return to(xs);
return xs;
}

@@ -194,7 +191,7 @@ exports.unsafeDeleteAt = unsafeDeleteAt;

function modifyAt(i, f, as) {
return isOutOfBound(i, as) ? option.none : updateAt(i, f(from(as)[i]), as);
return isOutOfBound(i, as) ? option.none : updateAt(i, f(as[i]), as);
}
exports.modifyAt = modifyAt;
function reverse(as) {
return to(copy(as).reverse());
return copy(as).reverse();
}

@@ -211,7 +208,8 @@ exports.reverse = reverse;

function sort(ord, as) {
return to(copy(as).sort(Ord_1.toNativeComparator(ord.compare)));
return copy(as).sort(Ord_1.toNativeComparator(ord.compare));
}
exports.sort = sort;
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, zero: exports.zero, alt: exports.alt });
({ empty: exports.empty, concat: concat, map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, zero: exports.zero, alt: exports.alt });
//# sourceMappingURL=Arr.js.map

@@ -55,4 +55,5 @@ "use strict";

exports.getApplicative = getApplicative;
// tslint:disable-next-line no-unused-expression
;
({ map: map, contramap: contramap });
//# sourceMappingURL=Const.js.map

@@ -21,5 +21,5 @@ import { HKT } from './HKT';

value: L;
static of: typeof of;
__hkt: HKT<URI, L>;
__hkta: A;
static of: typeof of;
constructor(value: L);

@@ -41,5 +41,5 @@ map<B>(f: Function1<A, B>): Either<L, B>;

value: A;
static of: typeof of;
__hkt: HKT<URI, L>;
__hkta: A;
static of: typeof of;
constructor(value: A);

@@ -46,0 +46,0 @@ map<B>(f: Function1<A, B>): Either<L, B>;

@@ -9,6 +9,6 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
static extract: typeof extract;
__hkt: URI;
__hkta: A;
static of: typeof of;
static extract: typeof extract;
constructor(value: A);

@@ -15,0 +15,0 @@ map<B>(f: Function1<A, B>): Identity<B>;

@@ -87,4 +87,5 @@ "use strict";

exports.extract = extract;
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain, reduce: reduce, traverse: traverse, alt: alt, extract: extract, extend: extend });
//# sourceMappingURL=Identity.js.map

@@ -9,5 +9,5 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
__hkt: URI;
__hkta: A;
static of: typeof of;
constructor(value: Lazy<A>);

@@ -14,0 +14,0 @@ run(): A;

@@ -59,4 +59,5 @@ "use strict";

exports.getMonoid = getMonoid;
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=IO.js.map

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

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -23,7 +24,7 @@ equals(setoid: Setoid<A>, fy: Option<A>): boolean;

export declare class None<A> implements Option<A> {
__hkt: URI;
__hkta: A;
static of: typeof of;
static zero: typeof zero;
static value: Option<any>;
__hkt: URI;
__hkta: A;
constructor();

@@ -38,2 +39,3 @@ map<B>(f: Function1<A, B>): Option<B>;

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -48,6 +50,6 @@ equals(setoid: Setoid<A>, fy: Option<A>): boolean;

value: A;
static of: typeof of;
static zero: typeof zero;
__hkt: URI;
__hkta: A;
static of: typeof of;
static zero: typeof zero;
constructor(value: A);

@@ -62,2 +64,3 @@ map<B>(f: Function1<A, B>): Option<B>;

fold<B>(n: Lazy<B>, s: Function1<A, B>): B;
getOrElse(f: Lazy<A>): A;
concat(semigroup: Semigroup<A>, fy: Option<A>): Option<A>;

@@ -64,0 +67,0 @@ equals(setoid: Setoid<any>, fy: Option<any>): boolean;

@@ -33,2 +33,5 @@ "use strict";

};
None.prototype.getOrElse = function (f) {
return f();
};
None.prototype.concat = function (semigroup, fy) {

@@ -86,2 +89,5 @@ return fy;

};
Some.prototype.getOrElse = function (f) {
return this.value;
};
Some.prototype.concat = function (semigroup, fy) {

@@ -88,0 +94,0 @@ var _this = this;

@@ -7,5 +7,5 @@ import { HKT } from './HKT';

private value;
static of: typeof of;
__hkt: HKT<URI, E>;
__hkta: A;
static of: typeof of;
constructor(value: Function1<E, A>);

@@ -12,0 +12,0 @@ run(e: E): A;

@@ -57,4 +57,5 @@ "use strict";

exports.local = local;
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=Reader.js.map

@@ -17,3 +17,6 @@ "use strict";

var _this = this;
return new State(function (s) { return [f(_this.eval(s)), s]; });
return new State(function (s) {
var _a = _this.run(s), a = _a[0], s1 = _a[1];
return [f(a), s1];
});
};

@@ -26,3 +29,6 @@ State.prototype.ap = function (fab) {

var _this = this;
return new State(function (s) { return (f(_this.eval(s))).run(s); });
return new State(function (s) {
var _a = _this.run(s), a = _a[0], s1 = _a[1];
return f(a).run(s1);
});
};

@@ -61,7 +67,8 @@ return State;

function gets(f) {
return get().chain(function (s) { return of(f(s)); });
return new State(function (s) { return [f(s), s]; });
}
exports.gets = gets;
// tslint:disable-next-line no-unused-expression
;
({ map: map, of: of, ap: ap, chain: chain });
//# sourceMappingURL=State.js.map
{
"name": "fp-ts",
"version": "0.0.2",
"version": "0.0.3",
"description": "Functional programming in TypeScript",

@@ -13,3 +13,5 @@ "files": [

"scripts": {
"test": "mocha -r ts-node/register test/*.ts",
"lint": "tslint src/**/*.ts test/**/*.ts",
"mocha": "mocha -r ts-node/register test/*.ts",
"test": "npm run lint && npm run mocha",
"build": "rm -rf lib/* && tsc && tsc -m es6 --outDir lib-jsnext"

@@ -33,2 +35,4 @@ },

"ts-node": "^2.0.0",
"tslint": "^4.4.2",
"tslint-config-standard": "^4.0.0",
"typescript": "^2.2.0"

@@ -35,0 +39,0 @@ },

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

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