Skip to content

Commit

Permalink
fix Invariant definition
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Jan 24, 2020
1 parent 083e860 commit 50cb556
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
**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.

# 2.4.2

- **Bug Fix**
- fix `Invariant` definition (@gcanti)

# 2.4.1

- **Polish**
Expand Down
36 changes: 32 additions & 4 deletions docs/modules/Invariant.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Added in v2.0.0
- [Invariant2 (interface)](#invariant2-interface)
- [Invariant2C (interface)](#invariant2c-interface)
- [Invariant3 (interface)](#invariant3-interface)
- [Invariant3C (interface)](#invariant3c-interface)
- [Invariant4 (interface)](#invariant4-interface)

---

Expand All @@ -40,7 +42,7 @@ Added in v2.0.0
```ts
export interface Invariant1<F extends URIS> {
readonly URI: F
readonly imap: <A, B>(fa: HKT<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>
readonly imap: <A, B>(fa: Kind<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>
}
```

Expand All @@ -53,7 +55,7 @@ Added in v2.0.0
```ts
export interface Invariant2<F extends URIS2> {
readonly URI: F
readonly imap: <E, A, B>(fa: HKT2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
readonly imap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}
```

Expand All @@ -67,7 +69,7 @@ Added in v2.0.0
export interface Invariant2C<F extends URIS2, E> {
readonly URI: F
readonly _E: E
readonly imap: <A, B>(fa: HKT2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
readonly imap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}
```

Expand All @@ -80,8 +82,34 @@ Added in v2.0.0
```ts
export interface Invariant3<F extends URIS3> {
readonly URI: F
readonly imap: <R, E, A, B>(fa: HKT3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
readonly imap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}
```

Added in v2.0.0

# Invariant3C (interface)

**Signature**

```ts
export interface Invariant3C<F extends URIS3, E> {
readonly URI: F
readonly imap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}
```

Added in v2.4.2

# Invariant4 (interface)

**Signature**

```ts
export interface Invariant4<F extends URIS4> {
readonly URI: F
readonly imap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind4<F, S, R, E, B>
}
```

Added in v2.4.2
11 changes: 11 additions & 0 deletions docs/modules/NonEmptyArray.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Added in v2.0.0
- [duplicate (export)](#duplicate-export)
- [extend (export)](#extend-export)
- [flatten (export)](#flatten-export)
- [fold (export)](#fold-export)
- [foldMap (export)](#foldmap-export)
- [foldMapWithIndex (export)](#foldmapwithindex-export)
- [map (export)](#map-export)
Expand Down Expand Up @@ -532,6 +533,16 @@ Added in v2.0.0

Added in v2.0.0

# fold (export)

**Signature**

```ts
;<A>(S: Semigroup<A>) => (fa: NonEmptyArray<A>) => A
```

Added in v2.5.0

# foldMap (export)

**Signature**
Expand Down
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": "2.4.1",
"version": "2.4.2",
"description": "Functional programming in TypeScript",
"files": [
"lib",
Expand Down
26 changes: 21 additions & 5 deletions src/Invariant.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @since 2.0.0
*/
import { HKT, HKT2, HKT3, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'
import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'

/**
* @since 2.0.0
Expand All @@ -16,15 +16,15 @@ export interface Invariant<F> {
*/
export interface Invariant1<F extends URIS> {
readonly URI: F
readonly imap: <A, B>(fa: HKT<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>
readonly imap: <A, B>(fa: Kind<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>
}

/**
* @since 2.0.0
*/
export interface Invariant2<F extends URIS2> {
readonly URI: F
readonly imap: <E, A, B>(fa: HKT2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
readonly imap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}

/**
Expand All @@ -33,13 +33,29 @@ export interface Invariant2<F extends URIS2> {
export interface Invariant2C<F extends URIS2, E> {
readonly URI: F
readonly _E: E
readonly imap: <A, B>(fa: HKT2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
readonly imap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>
}

/**
* @since 2.0.0
*/
export interface Invariant3<F extends URIS3> {
readonly URI: F
readonly imap: <R, E, A, B>(fa: HKT3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
readonly imap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}

/**
* @since 2.4.2
*/
export interface Invariant3C<F extends URIS3, E> {
readonly URI: F
readonly imap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>
}

/**
* @since 2.4.2
*/
export interface Invariant4<F extends URIS4> {
readonly URI: F
readonly imap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind4<F, S, R, E, B>
}

0 comments on commit 50cb556

Please sign in to comment.