Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload for zip for NonEmptyArray? #1109

Closed
vicrac opened this issue Jan 28, 2020 · 1 comment 路 Fixed by #1133, distributeaid/chat-ui#11, jianhan/fp-lib#33 or jianhan/fp-lib#40
Closed

Overload for zip for NonEmptyArray? #1109

vicrac opened this issue Jan 28, 2020 · 1 comment 路 Fixed by #1133, distributeaid/chat-ui#11, jianhan/fp-lib#33 or jianhan/fp-lib#40
Assignees
Milestone

Comments

@vicrac
Copy link
Contributor

vicrac commented Jan 28, 2020

馃殌 Feature request

Shouldn't there be an overload for zipping two NonEmptyArrays, resulting also in a NonEmptyArray?

Current Behavior

import { zip } from 'fp-ts/es6/Array';
import { head } from 'fp-ts/es6/NonEmptyArray';

head(zip([0], [1]))  // type error: Property '0' is missing in type '[number, number][]' but required in type 'NonEmptyArray<[number, number]>'

Desired Behavior

import { head, zip } from 'fp-ts/es6/NonEmptyArray';

head(zip([0], [1]))  // yields a tuple [0, 1]

Suggested Solution

a) add a zip implementation and signature to NonEmptyArray module
b) define an overload to zip in Array module

Who does this impact? Who is this for?

Anyone using zip with NonEmptyArrays

Describe alternatives you've considered

Asserting or filtering on Array's length? Non really convenient.

Your environment

Software Version(s)
fp-ts 2.4
TypeScript 3.7.3
@gcanti
Copy link
Owner

gcanti commented Jan 28, 2020

b) define an overload to zip in Array module

@vicrac to zip, zipWith and unzip I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment