Skip to content

Question: Is there an operator for zip? #160

Answered by stephencelis
amadeu01 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @amadeu01! The functionality of zip is typically achieved using curry alongside pure, and <*> (apply).

zip(with: User.init)(optionalId, optionalName, optionalEmail)

// vs.

pure(curry(User.init)) <*> optionalId <*> optionalName <*> optionalEmail

A shortcut to using pure is to sometimes use the map infix operator (<$> in Haskell, <¢> in this library):

curry(User.init) <¢> optionalId <*> optionalName <*> optionalEmail

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amadeu01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #127 on August 16, 2021 14:41.