From 3264973c590bb47d1243f6a47a745b94b800f337 Mon Sep 17 00:00:00 2001 From: gcanti Date: Fri, 5 Mar 2021 19:18:54 +0100 Subject: [PATCH] bump required fp-ts version --- CHANGELOG.md | 2 ++ dtslint/ts3.5/Lens.ts | 2 +- dtslint/ts3.5/Optional.ts | 2 +- dtslint/ts3.5/Prism.ts | 2 +- dtslint/ts3.5/Traversal.ts | 2 +- package-lock.json | 14 ++++++++++---- package.json | 4 ++-- scripts/FileSystem.ts | 6 +++--- scripts/build.ts | 21 +++++++++------------ scripts/pre-publish.ts | 2 +- scripts/release.ts | 4 ++-- scripts/run.ts | 4 ++-- src/At.ts | 4 ++-- src/Iso.ts | 3 ++- src/Ix.ts | 5 ++--- test/Iso.ts | 4 ++-- test/Lens.ts | 6 +++--- test/Optional.ts | 8 ++++---- test/Prism.ts | 8 ++++---- test/Traversal.ts | 2 +- 20 files changed, 55 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6cb182..02dac3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ high state of flux, you're at risk of it changing without notice. # 2.3.8 +Experimental modules require `fp-ts@^2.5.0`. + - **Experimental** - `Lens` - add `composeIso` (@gcanti) diff --git a/dtslint/ts3.5/Lens.ts b/dtslint/ts3.5/Lens.ts index 5a89375..23a2934 100644 --- a/dtslint/ts3.5/Lens.ts +++ b/dtslint/ts3.5/Lens.ts @@ -1,5 +1,5 @@ import * as L from '../../src/Lens' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' interface A { a: string diff --git a/dtslint/ts3.5/Optional.ts b/dtslint/ts3.5/Optional.ts index c220014..5917f1f 100644 --- a/dtslint/ts3.5/Optional.ts +++ b/dtslint/ts3.5/Optional.ts @@ -1,5 +1,5 @@ import * as O from '../../src/Optional' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' interface A { a: string diff --git a/dtslint/ts3.5/Prism.ts b/dtslint/ts3.5/Prism.ts index 2ee3db2..20840d3 100644 --- a/dtslint/ts3.5/Prism.ts +++ b/dtslint/ts3.5/Prism.ts @@ -1,5 +1,5 @@ import * as P from '../../src/Prism' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' interface A { a: string diff --git a/dtslint/ts3.5/Traversal.ts b/dtslint/ts3.5/Traversal.ts index 3729da8..e6169cf 100644 --- a/dtslint/ts3.5/Traversal.ts +++ b/dtslint/ts3.5/Traversal.ts @@ -1,5 +1,5 @@ import * as T from '../../src/Traversal' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' interface A { a: string diff --git a/package-lock.json b/package-lock.json index 11ffe4c..a3e04a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "monocle-ts", - "version": "2.3.7", + "version": "2.3.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1692,6 +1692,12 @@ "esutils": "^2.0.2" } }, + "fp-ts": { + "version": "2.9.5", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.9.5.tgz", + "integrity": "sha512-MiHrA5teO6t8zKArE3DdMPT/Db6v2GUt5yfWnhBTrrsVfeCJUUnV6sgFvjGNBKDmEMqVwRFkEePL7wPwqrLKKA==", + "dev": true + }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -2268,9 +2274,9 @@ } }, "fp-ts": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.9.5.tgz", - "integrity": "sha512-MiHrA5teO6t8zKArE3DdMPT/Db6v2GUt5yfWnhBTrrsVfeCJUUnV6sgFvjGNBKDmEMqVwRFkEePL7wPwqrLKKA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.5.0.tgz", + "integrity": "sha512-xkC9ZKl/i2cU+8FAsdyLcTvPRXphp42FcK5WmZpB47VXb4gggC3DHlVDKNLdbC+U8zz6yp1b0bj0mZg0axmZYQ==", "dev": true }, "fragment-cache": { diff --git a/package.json b/package.json index 4a35a29..58bc102 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ }, "homepage": "https://github.com/gcanti/monocle-ts", "peerDependencies": { - "fp-ts": "^2.0.0" + "fp-ts": "^2.5.0" }, "devDependencies": { "@types/glob": "^7.1.3", @@ -45,7 +45,7 @@ "@types/node": "^13.11.0", "docs-ts": "^0.6.2", "dtslint": "github:gcanti/dtslint", - "fp-ts": "^2.9.5", + "fp-ts": "^2.5.0", "import-path-rewrite": "github:gcanti/import-path-rewrite", "jest": "^24.3.0", "mocha": "^5.2.0", diff --git a/scripts/FileSystem.ts b/scripts/FileSystem.ts index 4fe66d3..f29ce0a 100644 --- a/scripts/FileSystem.ts +++ b/scripts/FileSystem.ts @@ -1,5 +1,5 @@ -import * as TE from 'fp-ts/TaskEither' -import { flow } from 'fp-ts/function' +import * as TE from 'fp-ts/lib/TaskEither' +import { flow } from 'fp-ts/lib/function' import * as fs from 'fs' import * as G from 'glob' @@ -25,6 +25,6 @@ export const fileSystem: FileSystem = { mkdir: flow( mkdirTE, TE.map(() => undefined), - TE.orElse((e) => (e.code === 'EEXIST' ? TE.of(undefined) : TE.left(e))) + TE.orElse((e) => (e.code === 'EEXIST' ? TE.right(undefined) : TE.left(e))) ) } diff --git a/scripts/build.ts b/scripts/build.ts index 05aa55c..e95c645 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,12 +1,12 @@ import * as path from 'path' -import * as E from 'fp-ts/Either' -import { pipe } from 'fp-ts/function' -import * as RTE from 'fp-ts/ReaderTaskEither' -import * as A from 'fp-ts/ReadonlyArray' -import * as TE from 'fp-ts/TaskEither' +import * as E from 'fp-ts/lib/Either' +import { pipe } from 'fp-ts/lib/pipeable' +import * as RTE from 'fp-ts/lib/ReaderTaskEither' +import * as A from 'fp-ts/lib/ReadonlyArray' +import * as TE from 'fp-ts/lib/TaskEither' import { FileSystem, fileSystem } from './FileSystem' import { run } from './run' -import * as O from 'fp-ts/Option' +import * as O from 'fp-ts/lib/Option' interface Build extends RTE.ReaderTaskEither {} @@ -32,18 +32,15 @@ export const copyPackageJson: Build = (C) => export const FILES: ReadonlyArray = ['CHANGELOG.md', 'LICENSE', 'README.md'] export const copyFiles: Build> = (C) => - pipe( - FILES, - A.traverse(TE.taskEither)((from) => C.copyFile(from, path.resolve(OUTPUT_FOLDER, from))) - ) + A.readonlyArray.traverse(TE.taskEither)(FILES, (from) => C.copyFile(from, path.resolve(OUTPUT_FOLDER, from))) -const traverse = A.traverse(TE.taskEither) +const traverse = A.readonlyArray.traverse(TE.taskEither) export const makeModules: Build = (C) => pipe( C.glob(`${OUTPUT_FOLDER}/lib/**/*.js`), TE.map(getModules), - TE.chain(traverse(makeSingleModule(C))), + TE.chain((modules) => traverse(modules, makeSingleModule(C))), TE.map(() => undefined) ) diff --git a/scripts/pre-publish.ts b/scripts/pre-publish.ts index 53dd325..01db991 100644 --- a/scripts/pre-publish.ts +++ b/scripts/pre-publish.ts @@ -1,4 +1,4 @@ -import { left } from 'fp-ts/TaskEither' +import { left } from 'fp-ts/lib/TaskEither' import { run } from './run' const main = left(new Error('"npm publish" can not be run from root, run "npm run release" instead')) diff --git a/scripts/release.ts b/scripts/release.ts index 750f3ed..418c37f 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -1,7 +1,7 @@ import { run } from './run' import * as child_process from 'child_process' -import { left, right } from 'fp-ts/Either' -import * as TE from 'fp-ts/TaskEither' +import { left, right } from 'fp-ts/lib/Either' +import * as TE from 'fp-ts/lib/TaskEither' const DIST = 'dist' diff --git a/scripts/run.ts b/scripts/run.ts index 7629fe1..6c259ef 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -1,5 +1,5 @@ -import { fold } from 'fp-ts/Either' -import { TaskEither } from 'fp-ts/TaskEither' +import { fold } from 'fp-ts/lib/Either' +import { TaskEither } from 'fp-ts/lib/TaskEither' export function run(eff: TaskEither): void { eff() diff --git a/src/At.ts b/src/At.ts index d96fcf6..d0ce3f8 100644 --- a/src/At.ts +++ b/src/At.ts @@ -60,7 +60,7 @@ export const atReadonlyMap = (E: Eq): (() => At ({ at: (key) => ({ - get: lookupE(key), + get: (s) => lookupE(key, s), set: O.fold( () => deleteAtE(key), (a) => insertAtE(key, a) @@ -82,7 +82,7 @@ export const atReadonlySet = (E: Eq): At, A, boolean> => { const insert = insertE(a) const remove = removeE(a) return { - get: elemE(a), + get: (s) => elemE(a, s), set: (b) => (s) => (b ? insert(s) : remove(s)) } } diff --git a/src/Iso.ts b/src/Iso.ts index 6940e04..112f004 100644 --- a/src/Iso.ts +++ b/src/Iso.ts @@ -15,7 +15,8 @@ * @since 2.3.0 */ import { Category2 } from 'fp-ts/lib/Category' -import { flow, identity, pipe } from 'fp-ts/lib/function' +import { flow, identity } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import { Functor, Functor1, Functor2, Functor3 } from 'fp-ts/lib/Functor' import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from 'fp-ts/lib/HKT' import { Invariant2 } from 'fp-ts/lib/Invariant' diff --git a/src/Ix.ts b/src/Ix.ts index acf822c..48796fd 100644 --- a/src/Ix.ts +++ b/src/Ix.ts @@ -73,14 +73,13 @@ export const indexReadonlyMap = (E: Eq): (() => Index ({ index: (key) => { - const lookup = lookupE(key) return { - getOption: lookup, + getOption: (s) => lookupE(key, s), set: (next) => { const insert = insertAtE(key, next) return (s) => pipe( - lookup(s), + lookupE(key, s), O.fold( () => s, (prev) => (next === prev ? s : insert(s)) diff --git a/test/Iso.ts b/test/Iso.ts index 466baeb..fca4f07 100644 --- a/test/Iso.ts +++ b/test/Iso.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import * as _ from '../src/Iso' import * as Id from 'fp-ts/lib/Identity' import * as O from 'fp-ts/lib/Option' @@ -63,7 +63,7 @@ describe('Iso', () => { it('modifyF', () => { const f = pipe( double, - _.modifyF(O.Functor)((n) => (n > 0 ? O.some(n * 2) : O.none)) + _.modifyF(O.option)((n) => (n > 0 ? O.some(n * 2) : O.none)) ) assert.deepStrictEqual(f(1), O.some(2)) assert.deepStrictEqual(f(-1), O.none) diff --git a/test/Lens.ts b/test/Lens.ts index 708a580..3420562 100644 --- a/test/Lens.ts +++ b/test/Lens.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' import * as _ from '../src/Lens' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import * as O from 'fp-ts/lib/Option' import * as A from 'fp-ts/lib/ReadonlyArray' import * as T from '../src/Traversal' @@ -46,7 +46,7 @@ describe('Lens', () => { const sa = pipe(_.id(), _.prop('a')) const ab = T.fromTraversable(A.readonlyArray)() const sb = pipe(sa, _.composeTraversal(ab)) - assert.deepStrictEqual(sb.modifyF(Id.Applicative)((n) => n * 2)({ a: [1, 2, 3] }), { a: [2, 4, 6] }) + assert.deepStrictEqual(sb.modifyF(Id.identity)((n) => n * 2)({ a: [1, 2, 3] }), { a: [2, 4, 6] }) }) it('id', () => { @@ -241,7 +241,7 @@ describe('Lens', () => { const sa: _.Lens = pipe(_.id(), _.prop('a')) const f = pipe( sa, - _.modifyF(O.Functor)((n) => (n > 0 ? O.some(n * 2) : O.none)) + _.modifyF(O.option)((n) => (n > 0 ? O.some(n * 2) : O.none)) ) assert.deepStrictEqual(f({ a: 1 }), O.some({ a: 2 })) assert.deepStrictEqual(f({ a: -1 }), O.none) diff --git a/test/Optional.ts b/test/Optional.ts index 8676e19..996f260 100644 --- a/test/Optional.ts +++ b/test/Optional.ts @@ -1,7 +1,7 @@ import * as assert from 'assert' import * as O from 'fp-ts/lib/Option' import * as _ from '../src/Optional' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import * as Id from 'fp-ts/lib/Identity' import * as A from 'fp-ts/lib/ReadonlyArray' import * as T from '../src/Traversal' @@ -72,8 +72,8 @@ describe('Optional', () => { const sa = pipe(L.id(), L.prop('a'), L.some) const ab = T.fromTraversable(A.readonlyArray)() const sb = pipe(sa, _.composeTraversal(ab)) - assert.deepStrictEqual(sb.modifyF(Id.Applicative)((n) => n * 2)({ a: O.none }), { a: O.none }) - assert.deepStrictEqual(sb.modifyF(Id.Applicative)((n) => n * 2)({ a: O.some([1, 2, 3]) }), { a: O.some([2, 4, 6]) }) + assert.deepStrictEqual(sb.modifyF(Id.identity)((n) => n * 2)({ a: O.none }), { a: O.none }) + assert.deepStrictEqual(sb.modifyF(Id.identity)((n) => n * 2)({ a: O.some([1, 2, 3]) }), { a: O.some([2, 4, 6]) }) }) it('id', () => { @@ -196,7 +196,7 @@ describe('Optional', () => { const sa = pipe(_.id>(), _.index(0)) const f = pipe( sa, - _.modifyF(O.Applicative)((n) => (n > 0 ? O.some(n * 2) : O.none)) + _.modifyF(O.option)((n) => (n > 0 ? O.some(n * 2) : O.none)) ) assert.deepStrictEqual(f([]), O.some([])) assert.deepStrictEqual(f([1, 2, 3]), O.some([2, 2, 3])) diff --git a/test/Prism.ts b/test/Prism.ts index 3ec3e38..dceffcf 100644 --- a/test/Prism.ts +++ b/test/Prism.ts @@ -1,5 +1,5 @@ import * as assert from 'assert' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import * as O from 'fp-ts/lib/Option' import * as E from 'fp-ts/lib/Either' import * as _ from '../src/Prism' @@ -162,8 +162,8 @@ describe('Prism', () => { const sa = pipe(_.id(), _.some) const ab = T.fromTraversable(A.readonlyArray)() const sb = pipe(sa, _.composeTraversal(ab)) - assert.deepStrictEqual(sb.modifyF(Id.Applicative)((n) => n * 2)(O.none), O.none) - assert.deepStrictEqual(sb.modifyF(Id.Applicative)((n) => n * 2)(O.some([1, 2, 3])), O.some([2, 4, 6])) + assert.deepStrictEqual(sb.modifyF(Id.identity)((n) => n * 2)(O.none), O.none) + assert.deepStrictEqual(sb.modifyF(Id.identity)((n) => n * 2)(O.some([1, 2, 3])), O.some([2, 4, 6])) }) it('right', () => { @@ -245,7 +245,7 @@ describe('Prism', () => { it('modifyF', () => { const f = pipe( value, - _.modifyF(O.Applicative)((n) => (n > 0 ? O.some(n * 2) : O.none)) + _.modifyF(O.option)((n) => (n > 0 ? O.some(n * 2) : O.none)) ) assert.deepStrictEqual(f(node(1, leaf, leaf)), O.some(node(2, leaf, leaf))) assert.deepStrictEqual(f(leaf), O.some(leaf)) diff --git a/test/Traversal.ts b/test/Traversal.ts index 95511ce..0ccdcbf 100644 --- a/test/Traversal.ts +++ b/test/Traversal.ts @@ -3,7 +3,7 @@ import * as _ from '../src/Traversal' import * as A from 'fp-ts/lib/ReadonlyArray' import * as Id from 'fp-ts/lib/Identity' import * as O from 'fp-ts/lib/Option' -import { pipe } from 'fp-ts/lib/function' +import { pipe } from 'fp-ts/lib/pipeable' import { monoidSum } from 'fp-ts/lib/Monoid' describe('Traversal', () => {