From 67c06a550a2a0d6e3c721f0d2fdf51ad546cd778 Mon Sep 17 00:00:00 2001 From: gcanti Date: Tue, 19 Mar 2019 12:31:13 +0100 Subject: [PATCH] version 1.15.0 --- CHANGELOG.md | 16 ++ README.md | 10 +- docs/index.md | 10 +- docs/modules/Apply.ts.md | 312 ++++--------------------------------- docs/recipes/purescript.md | 3 +- package.json | 2 +- 6 files changed, 63 insertions(+), 290 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a83872c..b1e1438d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,22 @@ **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.15.0 + +**Note**. This version requires `typescript@3.0.1+` (mapped tuples) + +- **New Feature** + - add `Apply.sequenceS`, closes #688 (@gcanti) + - make `function.tuple` variadic (@gcanti) + - make `Semigroup.getTupleSemigroup` variadic (@gcanti) + - make `Monoid.getTupleMonoid` variadic (@gcanti) + - make `Ord.getTupleOrd` variadic (@gcanti) + - make `Setoid.getTupleSetoid` variadic (@gcanti) + - make `Ring.getTupleRing` variadic (@gcanti) + - make `Apply.sequenceT` variadic (@gcanti) +- **Experimental** + - add `NonEmptyArray2v` module (type level non empty arrays), closes #735 (@gcanti) + # 1.14.4 - **Polish** diff --git a/README.md b/README.md index 8f760aaa5..3d7a1effc 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,14 @@ Make sure to always have a single version of `fp-ts` installed in your project. ## TypeScript compatibility -The stable version is tested against **TypeScript 3.3.3**, but should run with TypeScript 2.8.0+ too. +**Strictness** – This library is conceived, tested and is supposed to be consumed by TypeScript with the `strict` flag turned on. -- **Strictness** – This library is conceived, tested and is supposed to be consumed by TypeScript with the `strict` flag turned on. -- **Compatibility** – If you are running `< typescript@3.0.1` you have to polyfill the `unknown` type. You can use [unknown-ts](https://github.com/gcanti/unknown-ts) as a polyfill. +| `fp-ts` version | required `typescript` version | +| --------------- | ----------------------------- | +| 1.15.x+ | 3.1+ | +| <= 1.14.4 | 2.8+ (\*) | + +(\*) If you are running `< typescript@3.0.1` you have to polyfill the `unknown` type. You can use [unknown-ts](https://github.com/gcanti/unknown-ts) as a polyfill. # Documentation diff --git a/docs/index.md b/docs/index.md index 7929be6ab..170b37d29 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,7 +29,11 @@ Make sure to always have a single version of `fp-ts` installed in your project. ## TypeScript compatibility -The stable version is tested against **TypeScript 3.3.3**, but should run with TypeScript 2.8.0+ too. +**Strictness** – This library is conceived, tested and is supposed to be consumed by TypeScript with the `strict` flag turned on. -- **Strictness** – This library is conceived, tested and is supposed to be consumed by TypeScript with the `strict` flag turned on. -- **Compatibility** – If you are running `< typescript@3.0.1` you have to polyfill the `unknown` type. You can use [unknown-ts](https://github.com/gcanti/unknown-ts) as a polyfill. +| `fp-ts` version | required `typescript` version | +| --------------- | ----------------------------- | +| 1.15.x+ | 3.1+ | +| <= 1.14.4 | 2.8+ (\*) | + +(\*) If you are running `< typescript@3.0.1` you have to polyfill the `unknown` type. You can use [unknown-ts](https://github.com/gcanti/unknown-ts) as a polyfill. diff --git a/docs/modules/Apply.ts.md b/docs/modules/Apply.ts.md index da1de321d..3b6fc2708 100644 --- a/docs/modules/Apply.ts.md +++ b/docs/modules/Apply.ts.md @@ -27,12 +27,6 @@ Formally, `Apply` represents a strong lax semi-monoidal endofunctor. - [Apply2C (interface)](#apply2c-interface) - [Apply3 (interface)](#apply3-interface) - [Apply3C (interface)](#apply3c-interface) -- [SequenceT (interface)](#sequencet-interface) -- [SequenceT1 (interface)](#sequencet1-interface) -- [SequenceT2 (interface)](#sequencet2-interface) -- [SequenceT2C (interface)](#sequencet2c-interface) -- [SequenceT3 (interface)](#sequencet3-interface) -- [SequenceT3C (interface)](#sequencet3c-interface) - [applyFirst (function)](#applyfirst-function) - [applySecond (function)](#applysecond-function) - [getSemigroup (function)](#getsemigroup-function) @@ -106,276 +100,6 @@ export interface Apply3C extends Functor3C { } ``` -# SequenceT (interface) - -**Signature** - -```ts -export interface SequenceT { - (a: HKT): HKT - (a: HKT, b: HKT): HKT - (a: HKT, b: HKT, c: HKT): HKT - (a: HKT, b: HKT, c: HKT, d: HKT): HKT - (a: HKT, b: HKT, c: HKT, d: HKT, e: HKT): HKT - (a: HKT, b: HKT, c: HKT, d: HKT, e: HKT, g: HKT): HKT< - F, - [A, B, C, D, E, G] - > - ( - a: HKT, - b: HKT, - c: HKT, - d: HKT, - e: HKT, - g: HKT, - h: HKT - ): HKT - ( - a: HKT, - b: HKT, - c: HKT, - d: HKT, - e: HKT, - g: HKT, - h: HKT, - i: HKT - ): HKT -} -``` - -# SequenceT1 (interface) - -**Signature** - -```ts -export interface SequenceT1 { - (a: Type): Type - (a: Type, b: Type): Type - (a: Type, b: Type, c: Type): Type - (a: Type, b: Type, c: Type, d: Type): Type - (a: Type, b: Type, c: Type, d: Type, e: Type): Type - (a: Type, b: Type, c: Type, d: Type, e: Type, g: Type): Type< - F, - [A, B, C, D, E, G] - > - ( - a: Type, - b: Type, - c: Type, - d: Type, - e: Type, - g: Type, - h: Type - ): Type - ( - a: Type, - b: Type, - c: Type, - d: Type, - e: Type, - g: Type, - h: Type, - i: Type - ): Type -} -``` - -# SequenceT2 (interface) - -**Signature** - -```ts -export interface SequenceT2 { - (a: Type2): Type2 - (a: Type2, b: Type2): Type2 - (a: Type2, b: Type2, c: Type2): Type2 - (a: Type2, b: Type2, c: Type2, d: Type2): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2 - ): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2 - ): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2, - h: Type2 - ): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2, - h: Type2, - i: Type2 - ): Type2 -} -``` - -# SequenceT2C (interface) - -**Signature** - -```ts -export interface SequenceT2C { - (a: Type2): Type2 - (a: Type2, b: Type2): Type2 - (a: Type2, b: Type2, c: Type2): Type2 - (a: Type2, b: Type2, c: Type2, d: Type2): Type2 - (a: Type2, b: Type2, c: Type2, d: Type2, e: Type2): Type2< - F, - L, - [A, B, C, D, E] - > - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2 - ): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2, - h: Type2 - ): Type2 - ( - a: Type2, - b: Type2, - c: Type2, - d: Type2, - e: Type2, - g: Type2, - h: Type2, - i: Type2 - ): Type2 -} -``` - -# SequenceT3 (interface) - -**Signature** - -```ts -export interface SequenceT3 { - (a: Type3): Type3 - (a: Type3, b: Type3): Type3 - (a: Type3, b: Type3, c: Type3): Type3 - (a: Type3, b: Type3, c: Type3, d: Type3): Type3< - F, - U, - L, - [A, B, C, D] - > - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3, - h: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3, - h: Type3, - i: Type3 - ): Type3 -} -``` - -# SequenceT3C (interface) - -**Signature** - -```ts -export interface SequenceT3C { - (a: Type3): Type3 - (a: Type3, b: Type3): Type3 - (a: Type3, b: Type3, c: Type3): Type3 - (a: Type3, b: Type3, c: Type3, d: Type3): Type3< - F, - U, - L, - [A, B, C, D] - > - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3, - h: Type3 - ): Type3 - ( - a: Type3, - b: Type3, - c: Type3, - d: Type3, - e: Type3, - g: Type3, - h: Type3, - i: Type3 - ): Type3 -} -``` - # applyFirst (function) Combine two effectful actions, keeping only the result of the first @@ -641,12 +365,36 @@ Tuple sequencing, i.e., take a tuple of monadic actions and do them from left-to **Signature** ```ts -export function sequenceT(F: Apply3): SequenceT3 -export function sequenceT(F: Apply3C): SequenceT3C -export function sequenceT(F: Apply2): SequenceT2 -export function sequenceT(F: Apply2C): SequenceT2C -export function sequenceT(F: Apply1): SequenceT1 -export function sequenceT(F: Apply): SequenceT { ... } +export function sequenceT( + F: Apply3 +): >>( + ...t: T & { 0: Type3 } +) => Type3 ? A : never }> +export function sequenceT( + F: Apply3C +): >>( + ...t: T & { 0: Type3 } +) => Type3 ? A : never }> +export function sequenceT( + F: Apply2 +): >>( + ...t: T & { 0: Type2 } +) => Type2 ? A : never }> +export function sequenceT( + F: Apply2C +): >>( + ...t: T & { 0: Type2 } +) => Type2 ? A : never }> +export function sequenceT( + F: Apply1 +): >>( + ...t: T & { 0: Type } +) => Type ? A : never }> +export function sequenceT( + F: Apply +): >>( + ...t: T & { 0: HKT } +) => HKT ? A : never }> { ... } ``` **Example** diff --git a/docs/recipes/purescript.md b/docs/recipes/purescript.md index a6392c24e..91d062e79 100644 --- a/docs/recipes/purescript.md +++ b/docs/recipes/purescript.md @@ -235,7 +235,7 @@ A few options ```ts import { some, option } from 'fp-ts/lib/Option' -import { liftA2, sequenceT } from 'fp-ts/lib/Apply' +import { liftA2, sequenceT, sequenceS } from 'fp-ts/lib/Apply' const fa = some(1) const fb = some('foo') @@ -248,4 +248,5 @@ const fc2 = fb.ap(fa.ap(some(f))) const fc3 = fb.ap(fa.map(f)) const fc4 = liftA2(option)(f)(fa)(fb) const fc5 = sequenceT(option)(fa, fb).map(([a, b]) => f(a)(b)) +const fc6 = sequenceS(option)({ fa, fb }).map(({ fa: a, fb: b }) => f(a)(b)) ``` diff --git a/package.json b/package.json index 29291079b..8671ae89b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fp-ts", - "version": "1.14.4", + "version": "1.15.0", "description": "Functional programming in TypeScript", "files": [ "lib"