Skip to content

Commit

Permalink
upgrade fp-ts to 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Mar 6, 2021
1 parent 1f1fb85 commit c245666
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 36 deletions.
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"homepage": "https://github.com/gcanti/io-ts",
"dependencies": {},
"peerDependencies": {
"fp-ts": "^2.0.0"
"fp-ts": "^2.5.0"
},
"devDependencies": {
"@types/benchmark": "1.0.31",
Expand All @@ -54,7 +54,7 @@
"dtslint": "github:gcanti/dtslint",
"eslint": "^7.18.0",
"fast-check": "^1.24.2",
"fp-ts": "^2.9.5",
"fp-ts": "^2.5.0",
"import-path-rewrite": "github:gcanti/import-path-rewrite",
"jest": "25.2.7",
"mocha": "7.1.1",
Expand Down
4 changes: 2 additions & 2 deletions scripts/FileSystem.ts
Original file line number Diff line number Diff line change
@@ -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 G from 'glob'

Expand Down
19 changes: 8 additions & 11 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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'

Expand Down Expand Up @@ -31,18 +31,15 @@ export const copyPackageJson: Build<void> = (C) =>
export const FILES: ReadonlyArray<string> = ['CHANGELOG.md', 'LICENSE', 'README.md']

export const copyFiles: Build<ReadonlyArray<void>> = (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<void> = (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)
)

Expand Down
3 changes: 1 addition & 2 deletions scripts/pre-publish.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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'))

run(main)

4 changes: 2 additions & 2 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions scripts/run.ts
Original file line number Diff line number Diff line change
@@ -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<A>(eff: TaskEither<Error, A>): void {
eff()
Expand Down
16 changes: 14 additions & 2 deletions test/Codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ const codecInt: _.Codec<unknown, number, H.Int> = _.fromDecoder(H.decoderInt)

const codecUndefined: _.Codec<unknown, undefined, undefined> = _.fromDecoder(H.decoderUndefined)

export type Json = boolean | number | string | null | JsonArray | JsonRecord

export interface JsonRecord {
readonly [key: string]: Json
}

export interface JsonArray extends ReadonlyArray<Json> {}

export function parseJSON<E>(s: string, onError: (reason: unknown) => E): E.Either<E, Json> {
return E.tryCatch(() => JSON.parse(s), onError)
}

describe('Codec', () => {
describe('Invariant', () => {
it('imap', () => {
Expand Down Expand Up @@ -624,8 +636,8 @@ describe('Codec', () => {
encode: (s) => Buffer.from(s).toString('base64')
}

const Json: _.Codec<string, string, E.Json> = {
decode: (s) => E.parseJSON(s, () => D.error(s, 'Json')),
const Json: _.Codec<string, string, Json> = {
decode: (s) => parseJSON(s, () => D.error(s, 'Json')),
encode: (a) => JSON.stringify(a)
}

Expand Down
8 changes: 4 additions & 4 deletions test/Eq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Eq', () => {
})

it('intersect', () => {
const eq = pipe(E.type({ a: E.string }), E.intersect(E.type({ b: E.number })))
const eq = pipe(E.struct({ a: E.string }), E.intersect(E.struct({ b: E.number })))
assert.deepStrictEqual(eq.equals({ a: 'a', b: 1 }, { a: 'a', b: 1 }), true)
assert.deepStrictEqual(eq.equals({ a: 'a', b: 1 }, { a: 'c', b: 1 }), false)
assert.deepStrictEqual(eq.equals({ a: 'a', b: 1 }, { a: 'a', b: 2 }), false)
Expand All @@ -57,7 +57,7 @@ describe('Eq', () => {
}

const eq: Eq<A> = E.Schemable.lazy('A', () =>
E.type({
E.struct({
a: E.number,
b: E.array(eq)
})
Expand All @@ -71,8 +71,8 @@ describe('Eq', () => {
it('sum', () => {
const sum = E.sum('_tag')
const eq = sum({
A: E.type({ _tag: E.Schemable.literal('A'), a: E.string }),
B: E.type({ _tag: E.Schemable.literal('B'), b: E.number })
A: E.struct({ _tag: E.Schemable.literal('A'), a: E.string }),
B: E.struct({ _tag: E.Schemable.literal('B'), b: E.number })
})
assert.strictEqual(eq.equals({ _tag: 'A', a: 'a' }, { _tag: 'A', a: 'a' }), true)
assert.strictEqual(eq.equals({ _tag: 'B', b: 1 }, { _tag: 'B', b: 1 }), true)
Expand Down
4 changes: 2 additions & 2 deletions test/JsonSchema.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as assert from 'assert'
import Ajv from 'ajv'
import * as J from './JsonSchema'
import * as C from 'fp-ts/Const'
import { pipe } from 'fp-ts/function'
import * as C from 'fp-ts/lib/Const'
import { pipe } from 'fp-ts/lib/pipeable'

const ajv = new Ajv()

Expand Down
7 changes: 4 additions & 3 deletions test/JsonSchema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as C from 'fp-ts/Const'
import { identity, pipe } from 'fp-ts/function'
import * as R from 'fp-ts/ReadonlyRecord'
import * as C from 'fp-ts/lib/Const'
import { identity } from 'fp-ts/lib/function'
import { pipe } from 'fp-ts/lib/pipeable'
import * as R from 'fp-ts/lib/ReadonlyRecord'
import { JSONSchema7 } from 'json-schema'
import * as S from '../src/Schemable'

Expand Down

0 comments on commit c245666

Please sign in to comment.