diff --git a/docs/modules/Array.ts.md b/docs/modules/Array.ts.md
index 1c66ed6c1..bad6e768d 100644
--- a/docs/modules/Array.ts.md
+++ b/docs/modules/Array.ts.md
@@ -1687,7 +1687,10 @@ The function is reverse of `zip`. Takes an array of pairs and return two corresp
**Signature**
```ts
-export const unzip: (as: Array<[A, B]>) => [Array, Array] = ...
+export const unzip: {
+ (as: NonEmptyArray<[A, B]>): [NonEmptyArray, NonEmptyArray]
+ (as: Array<[A, B]>): [Array, Array]
+} = ...
```
**Example**
@@ -1740,7 +1743,10 @@ longer array are discarded
**Signature**
```ts
-export const zip: (fa: Array, fb: Array) => Array<[A, B]> = ...
+export const zip: {
+ (fa: NonEmptyArray, fb: NonEmptyArray): NonEmptyArray<[A, B]>
+ (fa: Array, fb: Array): Array<[A, B]>
+} = ...
```
**Example**
@@ -1765,7 +1771,10 @@ input array is short, excess elements of the longer array are discarded.
**Signature**
```ts
-export const zipWith: (fa: Array, fb: Array, f: (a: A, b: B) => C) => Array = ...
+export const zipWith: {
+ (fa: NonEmptyArray, fb: NonEmptyArray, f: (a: A, b: B) => C): NonEmptyArray
+ (fa: Array, fb: Array, f: (a: A, b: B) => C): Array
+} = ...
```
**Example**
diff --git a/docs/modules/ReadonlyArray.ts.md b/docs/modules/ReadonlyArray.ts.md
index 4725bcc12..d77951387 100644
--- a/docs/modules/ReadonlyArray.ts.md
+++ b/docs/modules/ReadonlyArray.ts.md
@@ -1720,6 +1720,9 @@ The function is reverse of `zip`. Takes an array of pairs and return two corresp
**Signature**
```ts
+export function unzip(
+ as: ReadonlyNonEmptyArray
+): readonly [ReadonlyNonEmptyArray, ReadonlyNonEmptyArray]
export function unzip(as: ReadonlyArray): readonly [ReadonlyArray, ReadonlyArray] { ... }
```
@@ -1773,6 +1776,10 @@ longer array are discarded
**Signature**
```ts
+export function zip(
+ fa: ReadonlyNonEmptyArray,
+ fb: ReadonlyNonEmptyArray
+): ReadonlyNonEmptyArray
export function zip(fa: ReadonlyArray, fb: ReadonlyArray): ReadonlyArray { ... }
```
@@ -1798,6 +1805,11 @@ input array is short, excess elements of the longer array are discarded.
**Signature**
```ts
+export function zipWith(
+ fa: ReadonlyNonEmptyArray,
+ fb: ReadonlyNonEmptyArray,
+ f: (a: A, b: B) => C
+): ReadonlyNonEmptyArray
export function zipWith(fa: ReadonlyArray, fb: ReadonlyArray, f: (a: A, b: B) => C): ReadonlyArray { ... }
```
diff --git a/dtslint/ts3.5/Array.ts b/dtslint/ts3.5/Array.ts
new file mode 100644
index 000000000..e991bb77c
--- /dev/null
+++ b/dtslint/ts3.5/Array.ts
@@ -0,0 +1,30 @@
+import * as _ from '../../src/Array'
+import { NonEmptyArray } from '../../src/NonEmptyArray'
+
+declare const ns: Array
+declare const ss: Array
+declare const nens: NonEmptyArray
+declare const sess: NonEmptyArray
+declare const tns: Array<[number, string]>
+declare const netns: NonEmptyArray<[number, string]>
+
+//
+// zip
+//
+
+_.zip(ns, ss) // $ExpectType [number, string][]
+_.zip(nens, sess) // $ExpectType NonEmptyArray<[number, string]>
+
+//
+// zipWith
+//
+
+_.zipWith(ns, ss, (n, s) => [n, s] as const) // $ExpectType (readonly [number, string])[]
+_.zipWith(nens, sess, (n, s) => [n, s] as const) // $ExpectType NonEmptyArray
+
+//
+// unzip
+//
+
+_.unzip(tns) // $ExpectType [number[], string[]]
+_.unzip(netns) // $ExpectType [NonEmptyArray, NonEmptyArray]
diff --git a/dtslint/ts3.5/ReadonlyArray.ts b/dtslint/ts3.5/ReadonlyArray.ts
new file mode 100644
index 000000000..ea2ccb7ba
--- /dev/null
+++ b/dtslint/ts3.5/ReadonlyArray.ts
@@ -0,0 +1,30 @@
+import * as _ from '../../src/ReadonlyArray'
+import { ReadonlyNonEmptyArray } from '../../src/ReadonlyNonEmptyArray'
+
+declare const ns: ReadonlyArray
+declare const ss: ReadonlyArray
+declare const nens: ReadonlyNonEmptyArray
+declare const sess: ReadonlyNonEmptyArray
+declare const tns: ReadonlyArray
+declare const netns: ReadonlyNonEmptyArray
+
+//
+// zip
+//
+
+_.zip(ns, ss) // $ExpectType readonly (readonly [number, string])[]
+_.zip(nens, sess) // $ExpectType ReadonlyNonEmptyArray
+
+//
+// zipWith
+//
+
+_.zipWith(ns, ss, (n, s) => [n, s] as const) // $ExpectType readonly (readonly [number, string])[]
+_.zipWith(nens, sess, (n, s) => [n, s] as const) // $ExpectType ReadonlyNonEmptyArray
+
+//
+// unzip
+//
+
+_.unzip(tns) // $ExpectType readonly [readonly number[], readonly string[]]
+_.unzip(netns) // $ExpectType readonly [ReadonlyNonEmptyArray, ReadonlyNonEmptyArray]
diff --git a/src/Array.ts b/src/Array.ts
index 17db05856..2fc461d39 100644
--- a/src/Array.ts
+++ b/src/Array.ts
@@ -671,7 +671,10 @@ export const sort: (O: Ord) => (as: Array) => Array = RA.sort as any
*
* @since 2.0.0
*/
-export const zipWith: (fa: Array, fb: Array, f: (a: A, b: B) => C) => Array = RA.zipWith as any
+export const zipWith: {
+ (fa: NonEmptyArray, fb: NonEmptyArray, f: (a: A, b: B) => C): NonEmptyArray
+ (fa: Array, fb: Array, f: (a: A, b: B) => C): Array
+} = RA.zipWith as any
/**
* Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the
@@ -684,7 +687,10 @@ export const zipWith: (fa: Array, fb: Array, f: (a: A, b: B) => C
*
* @since 2.0.0
*/
-export const zip: (fa: Array, fb: Array) => Array<[A, B]> = RA.zip as any
+export const zip: {
+ (fa: NonEmptyArray, fb: NonEmptyArray): NonEmptyArray<[A, B]>
+ (fa: Array, fb: Array): Array<[A, B]>
+} = RA.zip as any
/**
* The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays
@@ -696,7 +702,10 @@ export const zip: (fa: Array, fb: Array) => Array<[A, B]> = RA.zip a
*
* @since 2.0.0
*/
-export const unzip: (as: Array<[A, B]>) => [Array, Array] = RA.unzip as any
+export const unzip: {
+ (as: NonEmptyArray<[A, B]>): [NonEmptyArray, NonEmptyArray]
+ (as: Array<[A, B]>): [Array, Array]
+} = RA.unzip as any
/**
* Rotate an array to the right by `n` steps
diff --git a/src/ReadonlyArray.ts b/src/ReadonlyArray.ts
index b2dc65db7..5de35269e 100644
--- a/src/ReadonlyArray.ts
+++ b/src/ReadonlyArray.ts
@@ -990,6 +990,12 @@ export function sort(O: Ord): (as: ReadonlyArray) => ReadonlyArray {
*
* @since 2.5.0
*/
+export function zipWith(
+ fa: ReadonlyNonEmptyArray,
+ fb: ReadonlyNonEmptyArray,
+ f: (a: A, b: B) => C
+): ReadonlyNonEmptyArray
+export function zipWith(fa: ReadonlyArray, fb: ReadonlyArray, f: (a: A, b: B) => C): ReadonlyArray
export function zipWith(fa: ReadonlyArray, fb: ReadonlyArray, f: (a: A, b: B) => C): ReadonlyArray {
// tslint:disable-next-line: readonly-array
const fc: Array = []
@@ -1011,6 +1017,11 @@ export function zipWith(fa: ReadonlyArray, fb: ReadonlyArray, f:
*
* @since 2.5.0
*/
+export function zip(
+ fa: ReadonlyNonEmptyArray,
+ fb: ReadonlyNonEmptyArray
+): ReadonlyNonEmptyArray
+export function zip(fa: ReadonlyArray, fb: ReadonlyArray): ReadonlyArray
export function zip(fa: ReadonlyArray, fb: ReadonlyArray): ReadonlyArray {
return zipWith(fa, fb, (a, b) => [a, b])
}
@@ -1025,6 +1036,10 @@ export function zip(fa: ReadonlyArray, fb: ReadonlyArray): ReadonlyA
*
* @since 2.5.0
*/
+export function unzip(
+ as: ReadonlyNonEmptyArray
+): readonly [ReadonlyNonEmptyArray, ReadonlyNonEmptyArray]
+export function unzip(as: ReadonlyArray): readonly [ReadonlyArray, ReadonlyArray]
export function unzip(as: ReadonlyArray): readonly [ReadonlyArray, ReadonlyArray] {
// tslint:disable-next-line: readonly-array
const fa: Array = []