Skip to content

Commit

Permalink
version 1.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Feb 22, 2019
1 parent 8bb74eb commit 0f23e73
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
**Note**: Gaps between patch versions are faulty/broken releases. **Note**: A feature tagged as Experimental is in a
high state of flux, you're at risk of it changing without notice.

# 1.14.2

- **Deprecation**
- deprecate `Setoid.getRecordSetoid` in favour of `Setoid.getStructSetoid` (@gcanti)
- deprecate `Setoid.getProductSetoid` in favour of `Setoid.getTupleSetoid` (@gcanti)

# 1.14.1

- **New Feature**
Expand Down
38 changes: 32 additions & 6 deletions docs/Setoid.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Added in v1.0.0

## setoidDate

**Signature** (constant) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L89-L89)
**Signature** (constant) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L112-L112)

```ts
export const setoidDate: Setoid<Date> = ...
Expand Down Expand Up @@ -71,7 +71,7 @@ Added in v1.0.0

Returns the `Setoid` corresponding to the partitions of `B` induced by `f`

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L82-L84)
**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L105-L107)

```ts
export const contramap = <A, B>(f: (b: B) => A, fa: Setoid<A>): Setoid<B> => { ... }
Expand Down Expand Up @@ -99,19 +99,23 @@ export const getArraySetoid = <A>(S: Setoid<A>): Setoid<Array<A>> => { ... }

Added in v1.0.0

## getProductSetoid
## ~~getProductSetoid~~ (deprecated)

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L74-L76)
Use [getTupleSetoid](#gettuplesetoid) instead

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L96-L98)

```ts
export const getProductSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => { ... }
```

Added in v1.0.0

## getRecordSetoid
## ~~getRecordSetoid~~ (deprecated)

Use [getStructSetoid](#getstructsetoid) instead

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L59-L70)
**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L78-L82)

```ts
export const getRecordSetoid = <O extends { [key: string]: any }>(
Expand All @@ -121,6 +125,28 @@ export const getRecordSetoid = <O extends { [key: string]: any }>(

Added in v1.0.0

## getStructSetoid

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L60-L71)

```ts
export const getStructSetoid = <O extends { [key: string]: any }>(
setoids: { [K in keyof O]: Setoid<O[K]> }
): Setoid<O> => { ... }
```

Added in v1.14.2

## getTupleSetoid

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L87-L89)

```ts
export const getTupleSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => { ... }
```

Added in v1.14.2

## strictEqual

**Signature** (function) [Source](https://github.com/gcanti/fp-ts/blob/master/src/Setoid.ts#L29-L31)
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
branches: 100,
functions: 100,
lines: 100,
statements: 0
statements: 100
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fp-ts",
"version": "1.14.1",
"version": "1.14.2",
"description": "Functional programming in TypeScript",
"files": [
"lib"
Expand Down
29 changes: 26 additions & 3 deletions src/Setoid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export const setoidBoolean: Setoid<boolean> = setoidStrict
export const getArraySetoid = <A>(S: Setoid<A>): Setoid<Array<A>> => {
return fromEquals((xs, ys) => xs.length === ys.length && xs.every((x, i) => S.equals(x, ys[i])))
}

/**
* @since 1.0.0
* @since 1.14.2
*/
export const getRecordSetoid = <O extends { [key: string]: any }>(
export const getStructSetoid = <O extends { [key: string]: any }>(
setoids: { [K in keyof O]: Setoid<O[K]> }
): Setoid<O> => {
return fromEquals((x, y) => {
Expand All @@ -68,12 +69,34 @@ export const getRecordSetoid = <O extends { [key: string]: any }>(
return true
})
}

/**
* Use {@link getStructSetoid} instead
* @since 1.0.0
* @deprecated
*/
export const getProductSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => {
export const getRecordSetoid = <O extends { [key: string]: any }>(
setoids: { [K in keyof O]: Setoid<O[K]> }
): Setoid<O> => {
return getStructSetoid(setoids)
}

/**
* @since 1.14.2
*/
export const getTupleSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => {
return fromEquals((a, b) => SA.equals(a[0], b[0]) && SB.equals(a[1], b[1]))
}

/**
* Use {@link getTupleSetoid} instead
* @since 1.0.0
* @deprecated
*/
export const getProductSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => {
return getTupleSetoid(SA, SB)
}

/**
* Returns the `Setoid` corresponding to the partitions of `B` induced by `f`
*
Expand Down
6 changes: 3 additions & 3 deletions test/Set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
filterMap,
foldMap
} from '../src/Set'
import { Setoid, setoidNumber, setoidString, getRecordSetoid, contramap } from '../src/Setoid'
import { Setoid, setoidNumber, setoidString, contramap, getStructSetoid } from '../src/Setoid'
import { none, some as optionSome } from '../src/Option'
import { getArrayMonoid } from '../src/Monoid'

Expand Down Expand Up @@ -146,8 +146,8 @@ describe('Set', () => {
right: new Set(['1', '3'])
}
)
const SL = getRecordSetoid({ value: setoidNumber })
const SR = getRecordSetoid({ value: setoidString })
const SL = getStructSetoid({ value: setoidNumber })
const SR = getStructSetoid({ value: setoidString })
assert.deepStrictEqual(
partitionMap(SL, SR)(
new Set([{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }]),
Expand Down
2 changes: 2 additions & 0 deletions test/Setoid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('Setoid', () => {
})

it('getRecordSetoid', () => {
// tslint:disable-next-line: deprecation
const S = getRecordSetoid<Person>({
name: setoidString,
age: setoidNumber
Expand All @@ -42,6 +43,7 @@ describe('Setoid', () => {
})

it('getProductSetoid', () => {
// tslint:disable-next-line: deprecation
const S = getProductSetoid(setoidString, setoidNumber)
assert.strictEqual(S.equals(['a', 1], ['a', 1]), true)
assert.strictEqual(S.equals(['a', 1], ['b', 1]), false)
Expand Down

0 comments on commit 0f23e73

Please sign in to comment.