From 726407f224c2922136f7be3de06919f9f4fc3cb6 Mon Sep 17 00:00:00 2001 From: gcanti Date: Thu, 18 Apr 2019 12:32:45 +0200 Subject: [PATCH] Breaking Change: change type parameters of Either.left and Either.right, closes #543 --- dtslint/ts3.4/index.ts | 4 +- src/Apply.ts | 8 +- src/Either.ts | 8 +- src/Exception.ts | 2 +- src/TaskEither.ts | 3 +- test/Apply.ts | 8 +- test/Either.ts | 184 ++++++++++++++++++++--------------------- test/EitherT.ts | 2 +- test/FreeGroup.ts | 58 ++++++------- test/Map.ts | 5 +- test/Set.ts | 20 ++--- test/Tuple.ts | 5 +- test/Validation.ts | 4 +- 13 files changed, 144 insertions(+), 167 deletions(-) diff --git a/dtslint/ts3.4/index.ts b/dtslint/ts3.4/index.ts index 1d001ea84e..9e066dd419 100644 --- a/dtslint/ts3.4/index.ts +++ b/dtslint/ts3.4/index.ts @@ -290,8 +290,8 @@ R.sequence(O.option)(ro1) // $ExpectType Option> R.record.compact(do1) // $ExpectType Record -R.partitionMapWithKey(d1, (_k: string, n) => E.right(n)) // $ExpectType Separated, Record> -R.partitionMapWithKey(r1, (_k: 'a' | 'b', n) => E.right(n)) // $ExpectType Separated, Record> +R.partitionMapWithKey(d1, (_k: string, n): E.Either => E.right(n)) // $ExpectType Separated, Record> +R.partitionMapWithKey(r1, (_k: 'a' | 'b', n): E.Either => E.right(n)) // $ExpectType Separated, Record> R.partitionWithKey(d1, (_k: string, n) => n > 2) // $ExpectType Separated, Record> R.partitionWithKey(r1, (_k: 'a' | 'b', n) => n > 2) // $ExpectType Separated, Record> diff --git a/src/Apply.ts b/src/Apply.ts index 3f4945c35c..e159d85323 100644 --- a/src/Apply.ts +++ b/src/Apply.ts @@ -201,15 +201,15 @@ type EnforceNonEmptyRecord = keyof R extends never ? never : R * * assert.deepStrictEqual( * ado({ - * a: right(1), - * b: right(true) + * a: right(1), + * b: right(true) * }), * right({ a: 1, b: true }) * ) * assert.deepStrictEqual( * ado({ - * a: right(1), - * b: left('error') + * a: right(1), + * b: left('error') * }), * left('error') * ) diff --git a/src/Either.ts b/src/Either.ts index 7de82e519d..8e215d0749 100644 --- a/src/Either.ts +++ b/src/Either.ts @@ -357,7 +357,7 @@ const sequence = (F: Applicative) => (ta: Either>): HKT const chainRec = (a: A, f: (a: A) => Either>): Either => { return tailRec(f(a), e => { if (e.isLeft()) { - return right(left(e.value)) + return right>(left(e.value)) } else { const r = e.value return r.isLeft() ? left(f(r.value)) : right(right(r.value)) @@ -371,7 +371,7 @@ const chainRec = (a: A, f: (a: A) => Either>): Either(l: L): Either => { +export const left = (l: L): Either => { return new Left(l) } @@ -381,8 +381,8 @@ export const left = (l: L): Either => { * * @since 1.0.0 */ -export const right = (a: A): Either => { - return new Right(a) +export const right = (a: A): Either => { + return new Right(a) } const of = right diff --git a/src/Exception.ts b/src/Exception.ts index f412a94825..fe890e1f25 100644 --- a/src/Exception.ts +++ b/src/Exception.ts @@ -69,5 +69,5 @@ export const catchError = (ma: IO, handler: (e: Error) => IO): IO => * @since 1.0.0 */ export const tryCatch = (ma: IO): IO> => { - return catchError(ma.map>(right), e => io.of(left(e))) + return catchError(ma.map>(right), e => io.of(left(e))) } diff --git a/src/TaskEither.ts b/src/TaskEither.ts index 24d8d5d1ea..a05ad925fd 100644 --- a/src/TaskEither.ts +++ b/src/TaskEither.ts @@ -361,8 +361,7 @@ export function taskify(f: Function): () => TaskEither { new Task( () => new Promise(resolve => { - const cbResolver = (e: L, r: R) => - e != null ? resolve(eitherLeft(e)) : resolve(eitherRight(r)) + const cbResolver = (e: L, r: R) => (e != null ? resolve(eitherLeft(e)) : resolve(eitherRight(r))) f.apply(null, args.concat(cbResolver)) }) ) diff --git a/test/Apply.ts b/test/Apply.ts index 9f469e45b7..57b6833a5b 100644 --- a/test/Apply.ts +++ b/test/Apply.ts @@ -9,10 +9,10 @@ import { catOptions, getSetoid } from '../src/Array' import { fromEquals } from '../src/Setoid' describe('Apply', () => { - const r1 = right(1) - const r2 = right(2) - const foo = left('foo') - const bar = left('bar') + const r1 = right(1) + const r2 = right(2) + const foo = left('foo') + const bar = left('bar') it('applyFirst', () => { assert.deepStrictEqual(applyFirst(option)(some(5), some(6)), some(5)) diff --git a/test/Either.ts b/test/Either.ts index efe99141ba..ab61d34af0 100644 --- a/test/Either.ts +++ b/test/Either.ts @@ -1,6 +1,5 @@ import * as assert from 'assert' import { - Either, either, fromNullable, fromOption, @@ -22,12 +21,13 @@ import { right, stringifyJSON, toError, - tryCatch + tryCatch, + Either } from '../src/Either' import { identity } from '../src/function' import * as I from '../src/Identity' import { monoidString, monoidSum } from '../src/Monoid' -import { none, option, Option, some } from '../src/Option' +import { none, option, some } from '../src/Option' import { semigroupSum } from '../src/Semigroup' import { setoidNumber, setoidString } from '../src/Setoid' import { showString } from '../src/Show' @@ -37,54 +37,43 @@ describe('Either', () => { it('fold', () => { const f = (s: string) => `left${s.length}` const g = (s: string) => `right${s.length}` - assert.strictEqual(left('abc').fold(f, g), 'left3') - assert.strictEqual(right('abc').fold(f, g), 'right3') + assert.strictEqual(left('abc').fold(f, g), 'left3') + assert.strictEqual(right('abc').fold(f, g), 'right3') }) it('map', () => { const f = (s: string): number => s.length assert.deepStrictEqual(right('abc').map(f), right(3)) - assert.deepStrictEqual(left('s').map(f), left('s')) + assert.deepStrictEqual(left('s').map(f), left('s')) assert.deepStrictEqual(either.map(right('abc'), f), right(3)) - assert.deepStrictEqual(either.map(left('s'), f), left('s')) + assert.deepStrictEqual(either.map(left('s'), f), left('s')) }) it('bimap', () => { const f = (s: string): number => s.length const g = (n: number): boolean => n > 2 - assert.deepStrictEqual(right(1).bimap(f, g), right(false)) - assert.deepStrictEqual(left('foo').bimap(f, g), left(3)) - assert.deepStrictEqual(either.bimap(right(1), f, g), right(false)) + assert.deepStrictEqual(right(1).bimap(f, g), right(false)) + assert.deepStrictEqual(left('foo').bimap(f, g), left(3)) + assert.deepStrictEqual(either.bimap(right(1), f, g), right(false)) }) it('ap', () => { const f = (s: string): number => s.length - assert.deepStrictEqual(right('abc').ap(right number>(f)), right(3)) - assert.deepStrictEqual( - left('a').ap(right number>(f)), - left('a') - ) - assert.deepStrictEqual( - right('abc').ap(left number>('a')), - left('a') - ) - assert.deepStrictEqual( - left('b').ap(left number>('a')), - left('a') - ) + const abc: Either = right('abc') + assert.deepStrictEqual(right('abc').ap(right(f)), right(3)) + assert.deepStrictEqual(left('a').ap(right(f)), left('a')) + assert.deepStrictEqual(abc.ap(left('a')), left('a')) + assert.deepStrictEqual(left('b').ap(left('a')), left('a')) - assert.deepStrictEqual(right number>(f).ap_(right('abc')), right(3)) - assert.deepStrictEqual( - left number>('a').ap_(right('abc')), - left('a') - ) + assert.deepStrictEqual(right(f).ap_(right('abc')), right(3)) + assert.deepStrictEqual(left('a').ap_(right('abc')), left('a')) }) it('chain', () => { - const f = (s: string) => right(s.length) - assert.deepStrictEqual(right('abc').chain(f), right(3)) - assert.deepStrictEqual(left('a').chain(f), left('a')) - assert.deepStrictEqual(either.chain(right('abc'), f), right(3)) + const f = (s: string) => right(s.length) + assert.deepStrictEqual(right('abc').chain(f), right(3)) + assert.deepStrictEqual(left('a').chain(f), left('a')) + assert.deepStrictEqual(either.chain(right('abc'), f), right(3)) }) it('fromPredicate', () => { @@ -116,13 +105,15 @@ describe('Either', () => { it('getOrElse', () => { assert.deepStrictEqual(right(12).getOrElse(17), 12) - assert.deepStrictEqual(left('a').getOrElse(17), 17) + const l: Either = left('a') + assert.deepStrictEqual(l.getOrElse(17), 17) }) it('getOrElseL', () => { assert.deepStrictEqual(right(12).getOrElseL(() => 17), 12) - assert.deepStrictEqual(left('a').getOrElseL(() => 17), 17) - assert.deepStrictEqual(left('a').getOrElseL((l: string) => l.length + 1), 2) + const l: Either = left('a') + assert.deepStrictEqual(l.getOrElseL(() => 17), 17) + assert.deepStrictEqual(l.getOrElseL((l: string) => l.length + 1), 2) }) it('fromOption', () => { @@ -159,24 +150,24 @@ describe('Either', () => { it('sequence', () => { const sequence = either.sequence(option) - const x1 = right>(some('a')) + const x1 = right(some('a')) assert.deepStrictEqual(sequence(x1), some(right('a'))) - const x2 = left>(1) + const x2 = left(1) assert.deepStrictEqual(sequence(x2), some(left(1))) - const x3 = right>(none) + const x3 = right(none) assert.deepStrictEqual(sequence(x3), none) }) it('chainRec', () => { const chainRec = either.chainRec - assert.deepStrictEqual(chainRec(1, () => left>('foo')), left('foo')) - assert.deepStrictEqual(chainRec(1, () => right>(right(1))), right(1)) + assert.deepStrictEqual(chainRec(1, () => left('foo')), left('foo')) + assert.deepStrictEqual(chainRec(1, () => right(right(1))), right(1)) assert.deepStrictEqual( chainRec(1, a => { if (a < 5) { - return right>(left(a + 1)) + return right(left(a + 1)) } else { - return right>(right(a)) + return right(right(a)) } }), right(5) @@ -189,27 +180,36 @@ describe('Either', () => { }) it('filterOrElse', () => { - assert.deepStrictEqual(right(12).filterOrElse(n => n > 10, -1), right(12)) - assert.deepStrictEqual(right(7).filterOrElse(n => n > 10, -1), left(-1)) + const r1: Either = right(12) + assert.deepStrictEqual(r1.filterOrElse(n => n > 10, -1), right(12)) + const r2: Either = right(7) + assert.deepStrictEqual(r2.filterOrElse(n => n > 10, -1), left(-1)) assert.deepStrictEqual(left(12).filterOrElse(n => n > 10, -1), left(12)) type Color = 'red' | 'blue' const isColor = (s: string): s is Color => s === 'red' || s === 'blue' - assert.deepStrictEqual(right('red').filterOrElse(isColor, -1), right('red')) - assert.deepStrictEqual(right('foo').filterOrElse(isColor, -1), left(-1)) - assert.deepStrictEqual(left(12).filterOrElse(isColor, -1), left(12)) + const r3: Either = right('red') + assert.deepStrictEqual(r3.filterOrElse(isColor, -1), right('red')) + const r4: Either = right('foo') + assert.deepStrictEqual(r4.filterOrElse(isColor, -1), left(-1)) + assert.deepStrictEqual(left(12).filterOrElse(isColor, -1), left(12)) }) it('filterOrElseL', () => { - assert.deepStrictEqual(right(12).filterOrElseL(n => n > 10, () => -1), right(12)) - assert.deepStrictEqual(right(7).filterOrElseL(n => n > 10, () => -1), left(-1)) + const r1: Either = right(12) + assert.deepStrictEqual(r1.filterOrElseL(n => n > 10, () => -1), right(12)) + const r2: Either = right(7) + assert.deepStrictEqual(r2.filterOrElseL(n => n > 10, () => -1), left(-1)) assert.deepStrictEqual(left(12).filterOrElseL(n => n > 10, () => -1), left(12)) - assert.deepStrictEqual(right(7).filterOrElseL(n => n > 10, n => `invalid ${n}`), left('invalid 7')) + const r3: Either = right(7) + assert.deepStrictEqual(r3.filterOrElseL(n => n > 10, n => `invalid ${n}`), left('invalid 7')) type Color = 'red' | 'blue' const isColor = (s: string): s is Color => s === 'red' || s === 'blue' const errorHandler = (s: string) => `invalid color ${s}` - assert.deepStrictEqual(right('red').filterOrElseL(isColor, errorHandler), right('red')) - assert.deepStrictEqual(right('foo').filterOrElseL(isColor, errorHandler), left('invalid color foo')) - assert.deepStrictEqual(left('error').filterOrElseL(isColor, errorHandler), left('error')) + const r4: Either = right('red') + assert.deepStrictEqual(r4.filterOrElseL(isColor, errorHandler), right('red')) + const r5: Either = right('foo') + assert.deepStrictEqual(r5.filterOrElseL(isColor, errorHandler), left('invalid color foo')) + assert.deepStrictEqual(left('error').filterOrElseL(isColor, errorHandler), left('error')) }) it('isLeft', () => { @@ -227,21 +227,21 @@ describe('Either', () => { }) it('alt', () => { - assert.deepStrictEqual(right(1).alt(right(2)), right(1)) - assert.deepStrictEqual(right(1).alt(left('foo')), right(1)) - assert.deepStrictEqual(left('foo').alt(right(1)), right(1)) - assert.deepStrictEqual(left('foo').alt(left('bar')), left('bar')) - assert.deepStrictEqual(either.alt(right(1), right(2)), right(1)) + assert.deepStrictEqual(right(1).alt(right(2)), right(1)) + const r1: Either = right(1) + assert.deepStrictEqual(r1.alt(left('foo')), right(1)) + const l1: Either = left('foo') + assert.deepStrictEqual(l1.alt(right(1)), right(1)) + assert.deepStrictEqual(left('foo').alt(left('bar')), left('bar')) + assert.deepStrictEqual(either.alt(right(1), right(2)), right(1)) }) it('orElse', () => { - assert.deepStrictEqual(right(1).orElse(() => right(2)), right(1)) - assert.deepStrictEqual(right(1).orElse(() => left('foo')), right(1)) - assert.deepStrictEqual(left('foo').orElse(() => right(1)), right(1)) - assert.deepStrictEqual( - left('foo').orElse(() => left('bar')), - left('bar') - ) + assert.deepStrictEqual(right(1).orElse(() => right(2)), right(1)) + assert.deepStrictEqual(right(1).orElse(() => left('foo')), right(1)) + const l1: Either = left('foo') + assert.deepStrictEqual(l1.orElse(() => right(1)), right(1)) + assert.deepStrictEqual(left('foo').orElse(() => left('bar')), left('bar')) }) it('extend', () => { @@ -258,27 +258,27 @@ describe('Either', () => { it('foldMap', () => { const foldMap = either.foldMap(monoidString) - const x1 = right('a') + const x1 = right('a') const f1 = identity assert.strictEqual(foldMap(x1, f1), 'a') - const x2 = left(1) + const x2 = left(1) assert.strictEqual(foldMap(x2, f1), '') }) it('foldr', () => { const foldr = either.foldr - const x1 = right('a') + const x1 = right('a') const init1 = '' const f1 = (a: string, acc: string) => acc + a assert.strictEqual(foldr(x1, init1, f1), 'a') - const x2 = left(1) + const x2 = left(1) assert.strictEqual(foldr(x2, init1, f1), '') }) it('mapLeft', () => { const double = (n: number): number => n * 2 - assert.deepStrictEqual(right('bar').mapLeft(double), right('bar')) - assert.deepStrictEqual(left(2).mapLeft(double), left(4)) + assert.deepStrictEqual(right('bar').mapLeft(double), right('bar')) + assert.deepStrictEqual(left(2).mapLeft(double), left(4)) }) it('swap', () => { @@ -305,44 +305,44 @@ describe('Either', () => { const F = getFilterable(monoidString) const p = (n: number) => n > 2 it('partition', () => { - assert.deepStrictEqual(F.partition(left('123'), p), { + assert.deepStrictEqual(F.partition(left('123'), p), { left: left('123'), right: left('123') }) - assert.deepStrictEqual(F.partition(right(1), p), { + assert.deepStrictEqual(F.partition(right(1), p), { left: right(1), right: left(monoidString.empty) }) - assert.deepStrictEqual(F.partition(right(3), p), { + assert.deepStrictEqual(F.partition(right(3), p), { left: left(monoidString.empty), right: right(3) }) }) it('partitionMap', () => { const f = (n: number) => (p(n) ? right(n + 1) : left(n - 1)) - assert.deepStrictEqual(F.partitionMap(left('123'), f), { + assert.deepStrictEqual(F.partitionMap(left('123'), f), { left: left('123'), right: left('123') }) - assert.deepStrictEqual(F.partitionMap(right(1), f), { + assert.deepStrictEqual(F.partitionMap(right(1), f), { left: right(0), right: left(monoidString.empty) }) - assert.deepStrictEqual(F.partitionMap(right(3), f), { + assert.deepStrictEqual(F.partitionMap(right(3), f), { left: left(monoidString.empty), right: right(4) }) }) it('filter', () => { - assert.deepStrictEqual(F.filter(left('123'), p), left('123')) - assert.deepStrictEqual(F.filter(right(1), p), left(monoidString.empty)) - assert.deepStrictEqual(F.filter(right(3), p), right(3)) + assert.deepStrictEqual(F.filter(left('123'), p), left('123')) + assert.deepStrictEqual(F.filter(right(1), p), left(monoidString.empty)) + assert.deepStrictEqual(F.filter(right(3), p), right(3)) }) it('filterMap', () => { const f = (n: number) => (p(n) ? some(n + 1) : none) - assert.deepStrictEqual(F.filterMap(left('123'), f), left('123')) - assert.deepStrictEqual(F.filterMap(right(1), f), left(monoidString.empty)) - assert.deepStrictEqual(F.filterMap(right(3), f), right(4)) + assert.deepStrictEqual(F.filterMap(left('123'), f), left('123')) + assert.deepStrictEqual(F.filterMap(right(1), f), left(monoidString.empty)) + assert.deepStrictEqual(F.filterMap(right(3), f), right(4)) }) }) @@ -352,29 +352,29 @@ describe('Either', () => { it('wither', () => { const f = (n: number) => new I.Identity(p(n) ? some(n + 1) : none) const witherIdentity = W.wither(I.identity) - assert.deepStrictEqual(witherIdentity(left('foo'), f), new I.Identity(left('foo'))) - assert.deepStrictEqual(witherIdentity(right(1), f), new I.Identity(left(monoidString.empty))) - assert.deepStrictEqual(witherIdentity(right(3), f), new I.Identity(right(4))) + assert.deepStrictEqual(witherIdentity(left('foo'), f), new I.Identity(left('foo'))) + assert.deepStrictEqual(witherIdentity(right(1), f), new I.Identity(left(monoidString.empty))) + assert.deepStrictEqual(witherIdentity(right(3), f), new I.Identity(right(4))) }) it('wilt', () => { const wiltIdentity = W.wilt(I.identity) const f = (n: number) => new I.Identity(p(n) ? right(n + 1) : left(n - 1)) assert.deepStrictEqual( - wiltIdentity(left('foo'), f), + wiltIdentity(left('foo'), f), new I.Identity({ left: left('foo'), right: left('foo') }) ) assert.deepStrictEqual( - wiltIdentity(right(1), f), + wiltIdentity(right(1), f), new I.Identity({ left: right(0), right: left(monoidString.empty) }) ) assert.deepStrictEqual( - wiltIdentity(right(3), f), + wiltIdentity(right(3), f), new I.Identity({ left: left(monoidString.empty), right: right(4) @@ -384,7 +384,7 @@ describe('Either', () => { }) it('getSemigroup', () => { - const S = getSemigroup(semigroupSum) + const S = getSemigroup(semigroupSum) assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a')) assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2)) assert.deepStrictEqual(S.concat(right(1), left('b')), right(1)) @@ -392,7 +392,7 @@ describe('Either', () => { }) it('getApplySemigroup', () => { - const S = getApplySemigroup(semigroupSum) + const S = getApplySemigroup(semigroupSum) assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a')) assert.deepStrictEqual(S.concat(left('a'), right(2)), left('a')) assert.deepStrictEqual(S.concat(right(1), left('b')), left('b')) @@ -400,7 +400,7 @@ describe('Either', () => { }) it('getApplyMonoid', () => { - const S = getApplyMonoid(monoidSum) + const S = getApplyMonoid(monoidSum) assert.deepStrictEqual(S.concat(left('a'), S.empty), left('a')) assert.deepStrictEqual(S.concat(S.empty, left('b')), left('b')) assert.deepStrictEqual(S.concat(right(1), S.empty), right(1)) diff --git a/test/EitherT.ts b/test/EitherT.ts index f4726e66e1..9b7e421a12 100644 --- a/test/EitherT.ts +++ b/test/EitherT.ts @@ -8,7 +8,7 @@ describe('EitherT', () => { const { chain, of } = eitherT.getEitherT(task) const f = (n: number) => of(n * 2) const x = of(1) - const y = task.of(left('foo')) + const y = task.of(left('foo')) return Promise.all([chain(x, f).run(), chain(y, f).run()]).then(([e1, e2]) => { assert.deepStrictEqual(e1, right(2)) assert.deepStrictEqual(e2, left('foo')) diff --git a/test/FreeGroup.ts b/test/FreeGroup.ts index d3ee75cec9..b4153d260c 100644 --- a/test/FreeGroup.ts +++ b/test/FreeGroup.ts @@ -32,7 +32,7 @@ describe('FreeGroup', () => { }) it('of', () => { - assert.deepStrictEqual(freeGroup.of(1), new FreeGroup([right(1)])) + assert.deepStrictEqual(freeGroup.of(1), new FreeGroup([right(1)])) }) it('map', () => { @@ -48,14 +48,14 @@ describe('FreeGroup', () => { assert.deepStrictEqual( freeGroup.ap(fab, fa), new FreeGroup([ - left(false), - right(false), - left(true), - right(true), - left(true), - right(true), - left(false), - right(false) + left(false), + right(false), + left(true), + right(true), + left(true), + right(true), + left(false), + right(false) ]) ) assert.deepStrictEqual(fab.ap_(fa), fa.ap(fab)) @@ -63,32 +63,26 @@ describe('FreeGroup', () => { it('chain', () => { const fa = new FreeGroup([left(1), right(1), left(2), right(2)]) - const f = (n: number) => - new FreeGroup([ - left(n > 1), - right(n > 1), - left(n < 2), - right(n < 2) - ]) + const f = (n: number) => new FreeGroup([left(n > 1), right(n > 1), left(n < 2), right(n < 2)]) assert.deepStrictEqual( freeGroup.chain(fa, f), new FreeGroup([ - left(false), - right(false), - left(true), - right(true), - left(false), - right(false), - left(true), - right(true), - left(true), - right(true), - left(false), - right(false), - left(true), - right(true), - left(false), - right(false) + left(false), + right(false), + left(true), + right(true), + left(false), + right(false), + left(true), + right(true), + left(true), + right(true), + left(false), + right(false), + left(true), + right(true), + left(false), + right(false) ]) ) }) diff --git a/test/Map.ts b/test/Map.ts index 2b16456b4e..e74fa59478 100644 --- a/test/Map.ts +++ b/test/Map.ts @@ -365,10 +365,7 @@ describe('Map', () => { it('separate', () => { const separate = M.map.separate - const fooBar = new Map>([ - ['foo', left(123)], - ['bar', right(123)] - ]) + const fooBar = new Map>([['foo', left(123)], ['bar', right(123)]]) const foo = new Map([['foo', 123]]) const bar = new Map([['bar', 123]]) assert.deepStrictEqual(separate(fooBar), { diff --git a/test/Set.ts b/test/Set.ts index 9f0f992b9c..e7a2da6433 100644 --- a/test/Set.ts +++ b/test/Set.ts @@ -213,27 +213,17 @@ describe('Set', () => { }) it('separate', () => { - assert.deepStrictEqual( - separate(setoidString, setoidNumber)( - new Set([right(1), left('a'), right(2)]) - ), - { - left: new Set(['a']), - right: new Set([1, 2]) - } - ) + assert.deepStrictEqual(separate(setoidString, setoidNumber)(new Set([right(1), left('a'), right(2)])), { + left: new Set(['a']), + right: new Set([1, 2]) + }) type L = { error: string } type R = { id: string } const SL: Setoid = contramap(x => x.error, setoidString) const SR: Setoid = contramap(x => x.id, setoidString) assert.deepStrictEqual( separate(SL, SR)( - new Set([ - right({ id: 'a' }), - left({ error: 'error' }), - right({ id: 'a' }), - left({ error: 'error' }) - ]) + new Set([right({ id: 'a' }), left({ error: 'error' }), right({ id: 'a' }), left({ error: 'error' })]) ), { left: new Set([{ error: 'error' }]), diff --git a/test/Tuple.ts b/test/Tuple.ts index a932294007..0b63505071 100644 --- a/test/Tuple.ts +++ b/test/Tuple.ts @@ -146,10 +146,7 @@ describe('Tuple', () => { it('chainRec', () => { const { chainRec } = getChainRec(getArrayMonoid()) function seqReq(upper: number): Tuple, number> { - return chainRec( - 1, - init => new Tuple([init], init >= upper ? right(init) : left(init + 1)) - ) + return chainRec(1, init => new Tuple([init], init >= upper ? right(init) : left(init + 1))) } const xs = seqReq(10000).fst assert.strictEqual(xs.length, 10000) diff --git a/test/Validation.ts b/test/Validation.ts index 541672a3de..3527037f24 100644 --- a/test/Validation.ts +++ b/test/Validation.ts @@ -65,8 +65,8 @@ describe('Validation', () => { }) it('fromEither', () => { - assert.deepStrictEqual(fromEither(right(1)), success(1)) - assert.deepStrictEqual(fromEither(left('error')), failure('error')) + assert.deepStrictEqual(fromEither(right(1)), success(1)) + assert.deepStrictEqual(fromEither(left('error')), failure('error')) }) it('getSetoid', () => {