Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSuggestion: map2 variant that builds the cartesian product #547
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Apr 2, 2016
Contributor
First, please read https://github.com/elm-lang/core/blob/master/CONTRIBUTING.md#adding-new-functions.
So, such a function, if considered for addition, should first go into some *-extra package. And indeed, it already is: http://package.elm-lang.org/packages/circuithub/elm-list-extra/3.10.0/List-Extra#lift2.
About documentation: Maybe the current documentation for the List module in the core package should prepare against the surprise you encountered? You could make a suggestion for how to change the current documentation as shown at http://package.elm-lang.org/packages/elm-lang/core/3.0.0/List#map2. For that, please open a new issue or pull request.
|
First, please read https://github.com/elm-lang/core/blob/master/CONTRIBUTING.md#adding-new-functions. So, such a function, if considered for addition, should first go into some About documentation: Maybe the current documentation for the |
srijs commentedApr 2, 2016
Hi!
As someone coming to Elm from Haskell, I was quite surprised by the fact that map2 doesn't work coherently with concatMap.
I would have expected this to hold:
In other words,
map2building the cartesian product of both lists, instead of zipping. The reason I expected it is because I was looking atmap2andconcatMapas the Elm variants of<*>and>>=.I actually think that a zipping
map2is more approachable, so I like the way things currently are. However, I was wondering whether you would be open to adding the other functionality as well, under a different name (and possible extend the docs to make that clearer)?