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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe.concat and Maybe.concatMap #788

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@FRosner
Contributor

FRosner commented Dec 19, 2016

Problem

Elm does not have a generic implementation of higher order collection functions like map, filter, flatten/concat, etc. While this is not a problem per se it is useful to have the individual APIs available in a consistent way. This way you can generalize the API in your head when using it.

While, e.g., List.concat and List.concatMap exists, there is no Maybe.concat and Maybe.concatMap available.

Solution

Implement Maybe.concat and Maybe.concatMap in order to have a consistent API of both functions between List and Maybe.

Note

I read that you are strict about extending the core API and new functions should be proposed to *-extra first. While this makes sense for contributions that introduce additional concepts, this contribution adds already existing functionality to a place where it is missing. I think that having a consistent collection API is a strong feature and useful to have in the core API.

Anyway, ❤️ Elm.

Maybe.concat and Maybe.concatMap
- this is making the API consistent with List.concat and List.concatMap
@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Dec 19, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Dec 19, 2016

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby Dec 19, 2016

Member

Some quick thoughts I have:
concatMap and andThen are the same function, and concat can be derived from it as andThen identity. So the value here would be mostly in the names of the functions for consistency across List and Maybe rather than in previously unavailable functionality.

In any case, @FRosner, these kind of changes need to be discussed on the mailing list before any code gets accepted. Can you bring this up on elm-dev and get some feedback from other folks?

Member

lukewestby commented Dec 19, 2016

Some quick thoughts I have:
concatMap and andThen are the same function, and concat can be derived from it as andThen identity. So the value here would be mostly in the names of the functions for consistency across List and Maybe rather than in previously unavailable functionality.

In any case, @FRosner, these kind of changes need to be discussed on the mailing list before any code gets accepted. Can you bring this up on elm-dev and get some feedback from other folks?

@FRosner

This comment has been minimized.

Show comment
Hide comment
@FRosner

FRosner Dec 20, 2016

Contributor

You are totally right @lukewestby ¬_¬

So I guess I'll have to bring this up to the mailing list in terms of the consistency discussions (flatMap being called concatMap in List and andThen in Maybe).

Thanks for the comment.

Contributor

FRosner commented Dec 20, 2016

You are totally right @lukewestby ¬_¬

So I guess I'll have to bring this up to the mailing list in terms of the consistency discussions (flatMap being called concatMap in List and andThen in Maybe).

Thanks for the comment.

@FRosner FRosner closed this Dec 20, 2016

@richardhaven

This comment has been minimized.

Show comment
Hide comment
@richardhaven

richardhaven Jan 10, 2017

Emerson

As these methods do different things, rather than the same things on different objects, it is almost confusing that they have the same names.

richardhaven commented Jan 10, 2017

Emerson

As these methods do different things, rather than the same things on different objects, it is almost confusing that they have the same names.

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