fp-ts-representable
Advanced tools
Comparing version
@@ -29,3 +29,3 @@ /** | ||
*/ | ||
export declare type Coord = [x: number, y: number]; | ||
export declare type Coord = readonly [x: number, y: number]; | ||
declare module 'fp-ts/HKT' { | ||
@@ -104,3 +104,3 @@ interface URItoKind2<E, A> { | ||
*/ | ||
export declare const getShow: <A>(show: Show<A>, intercalation?: string) => Show<BoundedGrid<unknown, A>>; | ||
export declare const getShow: <K, A>(show: Show<A>, intercalation?: string) => Show<BoundedGrid<K, A>>; | ||
export {}; |
@@ -31,3 +31,3 @@ var __assign = (this && this.__assign) || function () { | ||
var x = _a[0], y = _a[1]; | ||
return grid.values[y % grid.values.length][x % grid.values[0].length]; | ||
return grid.values[(y + grid.values.length) % grid.values.length][(x + grid.values[0].length) % grid.values[0].length]; | ||
}; | ||
@@ -34,0 +34,0 @@ }; |
/** @since 1.0.0 */ | ||
import { Representable, Representable1, Representable2, Representable3, Representable4 } from './Representable'; | ||
import { Representable, Representable1, Representable2, Representable2C, Representable3, Representable3C, Representable4 } from './Representable'; | ||
import { Key, Keyed1, Keyed2, Keyed3, Keyed4, KeyOf1, KeyOf2, KeyOf3, KeyOf4 } from './Key'; | ||
import { Comonad2C } from 'fp-ts/Comonad'; | ||
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from 'fp-ts/HKT'; | ||
import { Functor2C } from 'fp-ts/Functor'; | ||
import { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C } from 'fp-ts/Functor'; | ||
import { Store } from 'fp-ts/Store'; | ||
import { Show } from 'fp-ts/lib/Show'; | ||
/** | ||
@@ -31,3 +32,5 @@ * @since 1.0.0 | ||
export declare function repStore<G extends URIS3 & Keyed3>(G: Representable3<G>): <R, E, A>(rep: Kind3<G, R, E, A>) => (pos: KeyOf3<G, R, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS3 & Keyed3, E>(G: Representable3C<G, E>): <R, A>(rep: Kind3<G, R, E, A>) => (pos: KeyOf3<G, R, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS2 & Keyed2>(G: Representable2<G>): <E, A>(rep: Kind2<G, E, A>) => (pos: KeyOf2<G, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): <A>(rep: Kind2<G, E, A>) => (pos: KeyOf2<G, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS & Keyed1>(G: Representable1<G>): <A>(rep: Kind<G, A>) => (pos: KeyOf1<G>) => RepStore<G, A>; | ||
@@ -44,2 +47,3 @@ export declare function repStore<G>(G: Representable<G>): <A>(rep: HKT<G, A>) => (pos: Key<G>) => RepStore<G, A>; | ||
*/ | ||
export declare function getFunctor<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): Functor2C<URI, G>; | ||
export declare function getFunctor<G extends URIS & Keyed1>(G: Representable1<G>): Functor2C<URI, G>; | ||
@@ -51,3 +55,31 @@ export declare function getFunctor<G>(G: Representable<G>): Functor2C<URI, G>; | ||
*/ | ||
export declare function getComonad<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): Comonad2C<URI, G>; | ||
export declare function getComonad<G extends URIS & Keyed1>(G: Representable1<G>): Comonad2C<URI, G>; | ||
export declare function getComonad<G>(G: Representable<G>): Comonad2C<URI, G>; | ||
interface Experiment<G, Key> { | ||
<F extends URIS3, E>(F: Functor3C<F, E>): <R>(f: (s: Key) => Kind3<F, R, E, Key>) => <A>(wa: RepStore<G, A>) => Kind3<F, R, E, A>; | ||
<F extends URIS3>(F: Functor3<F>): <R, E>(f: (s: Key) => Kind3<F, R, E, Key>) => <A>(wa: RepStore<G, A>) => Kind3<F, R, E, A>; | ||
<F extends URIS2, E>(F: Functor2C<F, E>): (f: (s: Key) => Kind2<F, E, Key>) => <A>(wa: RepStore<G, A>) => Kind2<F, E, A>; | ||
<F extends URIS2>(F: Functor2<F>): <E>(f: (s: Key) => Kind2<F, E, Key>) => <A>(wa: RepStore<G, A>) => Kind2<F, E, A>; | ||
<F extends URIS>(F: Functor1<F>): (f: (s: Key) => Kind<F, Key>) => <A>(wa: RepStore<G, A>) => Kind<F, A>; | ||
<F>(F: Functor<F>): (f: (s: Key) => HKT<F, Key>) => <A>(wa: RepStore<G, A>) => HKT<F, A>; | ||
} | ||
/** | ||
* @since 1.2.0 | ||
* @category Utils | ||
*/ | ||
export declare function experiment<G extends URIS2 & Keyed2, GE>(G: Representable2C<G, GE>): Experiment<G, KeyOf2<G, GE>>; | ||
export declare function experiment<G extends URIS & Keyed1>(G: Representable1<G>): Experiment<G, KeyOf1<G>>; | ||
export declare function experiment<G>(G: Representable<G>): Experiment<G, Key<G>>; | ||
/** | ||
* @since 1.2.0 | ||
* @category Instances | ||
*/ | ||
export declare const getShow: { | ||
<G extends URIS4, S, R, E, A>(GShow: Show<Kind4<G, S, R, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS3, R, E, A>(GShow: Show<Kind3<G, R, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS2, E, A>(GShow: Show<Kind2<G, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS, A>(GShow: Show<Kind<G, A>>): Show<RepStore<G, A>>; | ||
<G, A>(GShow: Show<HKT<G, A>>): Show<RepStore<G, A>>; | ||
}; | ||
export {}; |
@@ -39,1 +39,17 @@ /** @since 1.0.0 */ | ||
} | ||
export function experiment() { | ||
return function (F) { | ||
return function (f) { | ||
return function (wa) { | ||
return F.map(f(wa.pos), function (s) { return wa.peek(s); }); | ||
}; | ||
}; | ||
}; | ||
} | ||
/** | ||
* @since 1.2.0 | ||
* @category Instances | ||
*/ | ||
export var getShow = function (GShow) { return ({ | ||
show: function (rs) { return GShow.show(rs.rep); }, | ||
}); }; |
@@ -29,3 +29,3 @@ /** | ||
*/ | ||
export declare type Coord = [x: number, y: number]; | ||
export declare type Coord = readonly [x: number, y: number]; | ||
declare module 'fp-ts/HKT' { | ||
@@ -104,3 +104,3 @@ interface URItoKind2<E, A> { | ||
*/ | ||
export declare const getShow: <A>(show: Show<A>, intercalation?: string) => Show<BoundedGrid<unknown, A>>; | ||
export declare const getShow: <K, A>(show: Show<A>, intercalation?: string) => Show<BoundedGrid<K, A>>; | ||
export {}; |
@@ -57,3 +57,3 @@ "use strict"; | ||
var x = _a[0], y = _a[1]; | ||
return grid.values[y % grid.values.length][x % grid.values[0].length]; | ||
return grid.values[(y + grid.values.length) % grid.values.length][(x + grid.values[0].length) % grid.values[0].length]; | ||
}; | ||
@@ -60,0 +60,0 @@ }; |
/** @since 1.0.0 */ | ||
import { Representable, Representable1, Representable2, Representable3, Representable4 } from './Representable'; | ||
import { Representable, Representable1, Representable2, Representable2C, Representable3, Representable3C, Representable4 } from './Representable'; | ||
import { Key, Keyed1, Keyed2, Keyed3, Keyed4, KeyOf1, KeyOf2, KeyOf3, KeyOf4 } from './Key'; | ||
import { Comonad2C } from 'fp-ts/Comonad'; | ||
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from 'fp-ts/HKT'; | ||
import { Functor2C } from 'fp-ts/Functor'; | ||
import { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C } from 'fp-ts/Functor'; | ||
import { Store } from 'fp-ts/Store'; | ||
import { Show } from 'fp-ts/lib/Show'; | ||
/** | ||
@@ -31,3 +32,5 @@ * @since 1.0.0 | ||
export declare function repStore<G extends URIS3 & Keyed3>(G: Representable3<G>): <R, E, A>(rep: Kind3<G, R, E, A>) => (pos: KeyOf3<G, R, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS3 & Keyed3, E>(G: Representable3C<G, E>): <R, A>(rep: Kind3<G, R, E, A>) => (pos: KeyOf3<G, R, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS2 & Keyed2>(G: Representable2<G>): <E, A>(rep: Kind2<G, E, A>) => (pos: KeyOf2<G, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): <A>(rep: Kind2<G, E, A>) => (pos: KeyOf2<G, E>) => RepStore<G, A>; | ||
export declare function repStore<G extends URIS & Keyed1>(G: Representable1<G>): <A>(rep: Kind<G, A>) => (pos: KeyOf1<G>) => RepStore<G, A>; | ||
@@ -44,2 +47,3 @@ export declare function repStore<G>(G: Representable<G>): <A>(rep: HKT<G, A>) => (pos: Key<G>) => RepStore<G, A>; | ||
*/ | ||
export declare function getFunctor<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): Functor2C<URI, G>; | ||
export declare function getFunctor<G extends URIS & Keyed1>(G: Representable1<G>): Functor2C<URI, G>; | ||
@@ -51,3 +55,31 @@ export declare function getFunctor<G>(G: Representable<G>): Functor2C<URI, G>; | ||
*/ | ||
export declare function getComonad<G extends URIS2 & Keyed2, E>(G: Representable2C<G, E>): Comonad2C<URI, G>; | ||
export declare function getComonad<G extends URIS & Keyed1>(G: Representable1<G>): Comonad2C<URI, G>; | ||
export declare function getComonad<G>(G: Representable<G>): Comonad2C<URI, G>; | ||
interface Experiment<G, Key> { | ||
<F extends URIS3, E>(F: Functor3C<F, E>): <R>(f: (s: Key) => Kind3<F, R, E, Key>) => <A>(wa: RepStore<G, A>) => Kind3<F, R, E, A>; | ||
<F extends URIS3>(F: Functor3<F>): <R, E>(f: (s: Key) => Kind3<F, R, E, Key>) => <A>(wa: RepStore<G, A>) => Kind3<F, R, E, A>; | ||
<F extends URIS2, E>(F: Functor2C<F, E>): (f: (s: Key) => Kind2<F, E, Key>) => <A>(wa: RepStore<G, A>) => Kind2<F, E, A>; | ||
<F extends URIS2>(F: Functor2<F>): <E>(f: (s: Key) => Kind2<F, E, Key>) => <A>(wa: RepStore<G, A>) => Kind2<F, E, A>; | ||
<F extends URIS>(F: Functor1<F>): (f: (s: Key) => Kind<F, Key>) => <A>(wa: RepStore<G, A>) => Kind<F, A>; | ||
<F>(F: Functor<F>): (f: (s: Key) => HKT<F, Key>) => <A>(wa: RepStore<G, A>) => HKT<F, A>; | ||
} | ||
/** | ||
* @since 1.2.0 | ||
* @category Utils | ||
*/ | ||
export declare function experiment<G extends URIS2 & Keyed2, GE>(G: Representable2C<G, GE>): Experiment<G, KeyOf2<G, GE>>; | ||
export declare function experiment<G extends URIS & Keyed1>(G: Representable1<G>): Experiment<G, KeyOf1<G>>; | ||
export declare function experiment<G>(G: Representable<G>): Experiment<G, Key<G>>; | ||
/** | ||
* @since 1.2.0 | ||
* @category Instances | ||
*/ | ||
export declare const getShow: { | ||
<G extends URIS4, S, R, E, A>(GShow: Show<Kind4<G, S, R, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS3, R, E, A>(GShow: Show<Kind3<G, R, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS2, E, A>(GShow: Show<Kind2<G, E, A>>): Show<RepStore<G, A>>; | ||
<G extends URIS, A>(GShow: Show<Kind<G, A>>): Show<RepStore<G, A>>; | ||
<G, A>(GShow: Show<HKT<G, A>>): Show<RepStore<G, A>>; | ||
}; | ||
export {}; |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getComonad = exports.getFunctor = exports.repStore = exports.URI = void 0; | ||
exports.getShow = exports.experiment = exports.getComonad = exports.getFunctor = exports.repStore = exports.URI = void 0; | ||
/** | ||
@@ -46,1 +46,19 @@ * @since 1.0.0 | ||
exports.getComonad = getComonad; | ||
function experiment() { | ||
return function (F) { | ||
return function (f) { | ||
return function (wa) { | ||
return F.map(f(wa.pos), function (s) { return wa.peek(s); }); | ||
}; | ||
}; | ||
}; | ||
} | ||
exports.experiment = experiment; | ||
/** | ||
* @since 1.2.0 | ||
* @category Instances | ||
*/ | ||
var getShow = function (GShow) { return ({ | ||
show: function (rs) { return GShow.show(rs.rep); }, | ||
}); }; | ||
exports.getShow = getShow; |
{ | ||
"name": "fp-ts-representable", | ||
"homepage": "skeate.dev/fp-ts-representable", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"exports": { | ||
@@ -6,0 +6,0 @@ "./": { |
56009
20.66%32
6.67%1619
16.47%