From fd77356e76985a7f04ed28231b7eeb85dba58a85 Mon Sep 17 00:00:00 2001 From: DenisFrezzato Date: Sun, 31 Oct 2021 12:21:42 +0100 Subject: [PATCH] Add sequenceNonEmptyArray --- docs/modules/Either.ts.md | 13 ++++++++++++ docs/modules/IO.ts.md | 11 ++++++++++ docs/modules/IOEither.ts.md | 13 ++++++++++++ docs/modules/Option.ts.md | 13 ++++++++++++ docs/modules/Reader.ts.md | 13 ++++++++++++ docs/modules/ReaderEither.ts.md | 13 ++++++++++++ docs/modules/ReaderTaskEither.ts.md | 26 ++++++++++++++++++++++++ docs/modules/State.ts.md | 13 ++++++++++++ docs/modules/StateReaderTaskEither.ts.md | 13 ++++++++++++ docs/modules/Task.ts.md | 24 ++++++++++++++++++++++ docs/modules/TaskEither.ts.md | 26 ++++++++++++++++++++++++ docs/modules/TaskOption.ts.md | 26 ++++++++++++++++++++++++ src/Either.ts | 9 ++++++++ src/IO.ts | 7 +++++++ src/IOEither.ts | 9 ++++++++ src/Option.ts | 7 +++++++ src/Reader.ts | 9 ++++++++ src/ReaderEither.ts | 9 ++++++++ src/ReaderTaskEither.ts | 18 ++++++++++++++++ src/State.ts | 9 ++++++++ src/StateReaderTaskEither.ts | 9 ++++++++ src/Task.ts | 14 +++++++++++++ src/TaskEither.ts | 18 ++++++++++++++++ src/TaskOption.ts | 18 ++++++++++++++++ 24 files changed, 340 insertions(+) diff --git a/docs/modules/Either.ts.md b/docs/modules/Either.ts.md index dac4a4eeb..2ad105648 100644 --- a/docs/modules/Either.ts.md +++ b/docs/modules/Either.ts.md @@ -129,6 +129,7 @@ Added in v2.0.0 - [elem](#elem) - [exists](#exists) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [toError](#toerror) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) @@ -1565,6 +1566,18 @@ export declare const sequenceArray: (as: readonly Either[]) => Eithe Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + as: ReadonlyNonEmptyArray> +) => Either> +``` + +Added in v2.12.0 + ## toError Default value for the `onError` argument of `tryCatch` diff --git a/docs/modules/IO.ts.md b/docs/modules/IO.ts.md index 0ff85e840..4c5439318 100644 --- a/docs/modules/IO.ts.md +++ b/docs/modules/IO.ts.md @@ -62,6 +62,7 @@ Added in v2.0.0 - [bind](#bind) - [bindTo](#bindto) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -435,6 +436,16 @@ export declare const sequenceArray: (arr: readonly IO[]) => IO(arr: ReadonlyNonEmptyArray>) => IO> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/IOEither.ts.md b/docs/modules/IOEither.ts.md index acac84ef0..0d38b6029 100644 --- a/docs/modules/IOEither.ts.md +++ b/docs/modules/IOEither.ts.md @@ -118,6 +118,7 @@ Added in v2.0.0 - [bindW](#bindw) - [bracket](#bracket) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [sequenceSeqArray](#sequenceseqarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) @@ -1196,6 +1197,18 @@ export declare const sequenceArray: (arr: readonly IOEither[]) => IO Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => IOEither> +``` + +Added in v2.12.0 + ## sequenceSeqArray **Signature** diff --git a/docs/modules/Option.ts.md b/docs/modules/Option.ts.md index 0e67baed8..de15c641f 100644 --- a/docs/modules/Option.ts.md +++ b/docs/modules/Option.ts.md @@ -125,6 +125,7 @@ Added in v2.0.0 - [elem](#elem) - [exists](#exists) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -1587,6 +1588,18 @@ export declare const sequenceArray: (arr: readonly Option[]) => Option( + arr: ReadonlyNonEmptyArray> +) => Option> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/Reader.ts.md b/docs/modules/Reader.ts.md index 934796906..e78aeaefa 100644 --- a/docs/modules/Reader.ts.md +++ b/docs/modules/Reader.ts.md @@ -75,6 +75,7 @@ Added in v2.0.0 - [bindTo](#bindto) - [bindW](#bindw) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -671,6 +672,18 @@ export declare const sequenceArray: (arr: readonly Reader[]) => Read Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => Reader> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/ReaderEither.ts.md b/docs/modules/ReaderEither.ts.md index 72d098f0d..a8b74928a 100644 --- a/docs/modules/ReaderEither.ts.md +++ b/docs/modules/ReaderEither.ts.md @@ -116,6 +116,7 @@ Added in v2.0.0 - [bindTo](#bindto) - [bindW](#bindw) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -1251,6 +1252,18 @@ export declare const sequenceArray: (arr: readonly ReaderEither( + arr: ReadonlyNonEmptyArray> +) => ReaderEither> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md index ec10be853..e266132a6 100644 --- a/docs/modules/ReaderTaskEither.ts.md +++ b/docs/modules/ReaderTaskEither.ts.md @@ -159,7 +159,9 @@ Added in v2.0.0 - [bindW](#bindw) - [bracket](#bracket) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [sequenceSeqArray](#sequenceseqarray) + - [sequenceSeqNonEmptyArray](#sequenceseqnonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -1823,6 +1825,18 @@ export declare const sequenceArray: ( Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => ReaderTaskEither> +``` + +Added in v2.12.0 + ## sequenceSeqArray **Signature** @@ -1835,6 +1849,18 @@ export declare const sequenceSeqArray: ( Added in v2.9.0 +## sequenceSeqNonEmptyArray + +**Signature** + +```ts +export declare const sequenceSeqNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => ReaderTaskEither> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/State.ts.md b/docs/modules/State.ts.md index 1d693d443..698ad9b30 100644 --- a/docs/modules/State.ts.md +++ b/docs/modules/State.ts.md @@ -51,6 +51,7 @@ Added in v2.0.0 - [evaluate](#evaluate) - [execute](#execute) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -424,6 +425,18 @@ export declare const sequenceArray: (arr: readonly State[]) => State Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => State> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/StateReaderTaskEither.ts.md b/docs/modules/StateReaderTaskEither.ts.md index c626c7b77..19db2a209 100644 --- a/docs/modules/StateReaderTaskEither.ts.md +++ b/docs/modules/StateReaderTaskEither.ts.md @@ -131,6 +131,7 @@ Added in v2.0.0 - [evaluate](#evaluate) - [execute](#execute) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -1468,6 +1469,18 @@ export declare const sequenceArray: ( Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => StateReaderTaskEither> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/Task.ts.md b/docs/modules/Task.ts.md index c5553ece4..e370b32a9 100644 --- a/docs/modules/Task.ts.md +++ b/docs/modules/Task.ts.md @@ -73,7 +73,9 @@ Added in v2.0.0 - [bindTo](#bindto) - [never](#never) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [sequenceSeqArray](#sequenceseqarray) + - [sequenceSeqNonEmptyArray](#sequenceseqnonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -613,6 +615,16 @@ export declare const sequenceArray: (arr: readonly Task[]) => Task(arr: ReadonlyNonEmptyArray>) => Task> +``` + +Added in v2.12.0 + ## sequenceSeqArray **Signature** @@ -623,6 +635,18 @@ export declare const sequenceSeqArray: (arr: readonly Task[]) => Task( + arr: ReadonlyNonEmptyArray> +) => Task> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/docs/modules/TaskEither.ts.md b/docs/modules/TaskEither.ts.md index 4482de600..81b5e1eaf 100644 --- a/docs/modules/TaskEither.ts.md +++ b/docs/modules/TaskEither.ts.md @@ -138,7 +138,9 @@ Added in v2.0.0 - [bindW](#bindw) - [bracket](#bracket) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [sequenceSeqArray](#sequenceseqarray) + - [sequenceSeqNonEmptyArray](#sequenceseqnonemptyarray) - [taskify](#taskify) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) @@ -1473,6 +1475,18 @@ export declare const sequenceArray: (arr: readonly TaskEither[]) => Added in v2.9.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => TaskEither> +``` + +Added in v2.12.0 + ## sequenceSeqArray **Signature** @@ -1483,6 +1497,18 @@ export declare const sequenceSeqArray: (arr: readonly TaskEither[]) Added in v2.9.0 +## sequenceSeqNonEmptyArray + +**Signature** + +```ts +export declare const sequenceSeqNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => TaskEither> +``` + +Added in v2.12.0 + ## taskify Convert a node style callback function to one returning a `TaskEither` diff --git a/docs/modules/TaskOption.ts.md b/docs/modules/TaskOption.ts.md index 738f0a35b..a0308ebb2 100644 --- a/docs/modules/TaskOption.ts.md +++ b/docs/modules/TaskOption.ts.md @@ -102,7 +102,9 @@ Added in v2.10.0 - [bind](#bind) - [bindTo](#bindto) - [sequenceArray](#sequencearray) + - [sequenceNonEmptyArray](#sequencenonemptyarray) - [sequenceSeqArray](#sequenceseqarray) + - [sequenceSeqNonEmptyArray](#sequenceseqnonemptyarray) - [traverseArray](#traversearray) - [traverseArrayWithIndex](#traversearraywithindex) - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex) @@ -966,6 +968,18 @@ export declare const sequenceArray: (as: readonly TaskOption[]) => TaskOpt Added in v2.10.0 +## sequenceNonEmptyArray + +**Signature** + +```ts +export declare const sequenceNonEmptyArray: ( + as: ReadonlyNonEmptyArray> +) => TaskOption> +``` + +Added in v2.12.0 + ## sequenceSeqArray **Signature** @@ -976,6 +990,18 @@ export declare const sequenceSeqArray: (as: readonly TaskOption[]) => Task Added in v2.10.0 +## sequenceSeqNonEmptyArray + +**Signature** + +```ts +export declare const sequenceSeqNonEmptyArray: ( + as: ReadonlyNonEmptyArray> +) => TaskOption> +``` + +Added in v2.12.0 + ## traverseArray **Signature** diff --git a/src/Either.ts b/src/Either.ts index f904a2223..0ba3294f9 100644 --- a/src/Either.ts +++ b/src/Either.ts @@ -1372,6 +1372,15 @@ export const sequenceArray: (as: ReadonlyArray>) => Either( + as: ReadonlyNonEmptyArray> +) => Either> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/IO.ts b/src/IO.ts index 21f2f632b..2679506d3 100644 --- a/src/IO.ts +++ b/src/IO.ts @@ -369,6 +369,13 @@ export const sequenceArray: (arr: ReadonlyArray>) => IO(arr: ReadonlyNonEmptyArray>) => IO> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/IOEither.ts b/src/IOEither.ts index 830a70d22..2521c24f7 100644 --- a/src/IOEither.ts +++ b/src/IOEither.ts @@ -1010,6 +1010,15 @@ export const sequenceArray: (arr: ReadonlyArray>) => IOEith /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => IOEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + /** * @since 2.9.0 */ diff --git a/src/Option.ts b/src/Option.ts index c715ca748..afdb28d3a 100644 --- a/src/Option.ts +++ b/src/Option.ts @@ -1278,6 +1278,13 @@ export const sequenceArray: (arr: ReadonlyArray>) => Option(arr: ReadonlyNonEmptyArray>) => Option> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/Reader.ts b/src/Reader.ts index 1a06432a6..ac16d91b5 100644 --- a/src/Reader.ts +++ b/src/Reader.ts @@ -517,6 +517,15 @@ export const sequenceArray: (arr: ReadonlyArray>) => Reader( + arr: ReadonlyNonEmptyArray> +) => Reader> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/ReaderEither.ts b/src/ReaderEither.ts index 65df1c170..1400863b9 100644 --- a/src/ReaderEither.ts +++ b/src/ReaderEither.ts @@ -1006,6 +1006,15 @@ export const sequenceArray: ( /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => ReaderEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts index dfa68bca6..5a8a7bc16 100644 --- a/src/ReaderTaskEither.ts +++ b/src/ReaderTaskEither.ts @@ -1443,6 +1443,15 @@ export const sequenceArray: ( /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => ReaderTaskEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + /** * @since 2.9.0 */ @@ -1467,6 +1476,15 @@ export const sequenceSeqArray: ( /*#__PURE__*/ traverseSeqArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceSeqNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => ReaderTaskEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndexSeq((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/State.ts b/src/State.ts index 2878a2679..b0a3eba45 100644 --- a/src/State.ts +++ b/src/State.ts @@ -369,6 +369,15 @@ export const sequenceArray: (arr: ReadonlyArray>) => State( + arr: ReadonlyNonEmptyArray> +) => State> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/StateReaderTaskEither.ts b/src/StateReaderTaskEither.ts index a25de670b..dc86fc1d3 100644 --- a/src/StateReaderTaskEither.ts +++ b/src/StateReaderTaskEither.ts @@ -1208,6 +1208,15 @@ export const sequenceArray: ( /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => StateReaderTaskEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/Task.ts b/src/Task.ts index 57256baac..aba4e8469 100644 --- a/src/Task.ts +++ b/src/Task.ts @@ -552,6 +552,13 @@ export const sequenceArray: (arr: ReadonlyArray>) => Task(arr: ReadonlyNonEmptyArray>) => Task> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + /** * @since 2.9.0 */ @@ -572,6 +579,13 @@ export const sequenceSeqArray: (arr: ReadonlyArray>) => Task(arr: ReadonlyNonEmptyArray>) => Task> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndexSeq((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/TaskEither.ts b/src/TaskEither.ts index 28c4608fa..123e1fc3b 100644 --- a/src/TaskEither.ts +++ b/src/TaskEither.ts @@ -1288,6 +1288,15 @@ export const sequenceArray: (arr: ReadonlyArray>) => Task /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => TaskEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + /** * @since 2.9.0 */ @@ -1309,6 +1318,15 @@ export const sequenceSeqArray: (arr: ReadonlyArray>) => T /*#__PURE__*/ traverseSeqArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceSeqNonEmptyArray: ( + arr: ReadonlyNonEmptyArray> +) => TaskEither> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndexSeq((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // ------------------------------------------------------------------------------------- diff --git a/src/TaskOption.ts b/src/TaskOption.ts index f38f7f308..6656af8f0 100644 --- a/src/TaskOption.ts +++ b/src/TaskOption.ts @@ -883,6 +883,15 @@ export const sequenceArray: (as: ReadonlyArray>) => TaskOption< /*#__PURE__*/ traverseArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceNonEmptyArray: ( + as: ReadonlyNonEmptyArray> +) => TaskOption> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndex((_, a) => a) + /** * @since 2.10.0 */ @@ -904,6 +913,15 @@ export const sequenceSeqArray: (as: ReadonlyArray>) => TaskOpti /*#__PURE__*/ traverseSeqArray(identity) +/** + * @since 2.12.0 + */ +export const sequenceSeqNonEmptyArray: ( + as: ReadonlyNonEmptyArray> +) => TaskOption> = + /*#__PURE__*/ + traverseReadonlyNonEmptyArrayWithIndexSeq((_, a) => a) + // ------------------------------------------------------------------------------------- // deprecated // -------------------------------------------------------------------------------------