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

List.singleton clarity #860

Closed
tibastral opened this Issue Apr 27, 2017 · 7 comments

Comments

Projects
None yet
7 participants
@tibastral
Contributor

tibastral commented Apr 27, 2017

Hello everybody,

List.singleton seems a little confusing, especially for people coming from OOP. As stated, we want to be mainstream.

Mathematically, List.unit would work as well and would be a little less confusing. Stack overflow discussion, Wikipedia

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Apr 27, 2017

Thanks for the issue! 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 Apr 27, 2017

Thanks for the issue! 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.

@simonewebdesign

This comment has been minimized.

Show comment
Hide comment
@simonewebdesign

simonewebdesign Apr 27, 2017

To be fair, we might as well just remove it.

The implementation actually just wraps the value in [], so if the function name is confusing I don't see any point in keeping it.
Are there any use cases for it?

simonewebdesign commented Apr 27, 2017

To be fair, we might as well just remove it.

The implementation actually just wraps the value in [], so if the function name is confusing I don't see any point in keeping it.
Are there any use cases for it?

@tibastral

This comment has been minimized.

Show comment
Hide comment
@tibastral

tibastral Apr 27, 2017

Contributor

Yes it's useful. It allows to be point free.

Contributor

tibastral commented Apr 27, 2017

Yes it's useful. It allows to be point free.

@Angarsk8

This comment has been minimized.

Show comment
Hide comment
@Angarsk8

Angarsk8 May 3, 2017

I was wondering the same today. This is current implementation of the singleton/1 function:

singleton : a -> List a
singleton value =
  [value]

IMHO something that simple should not be abstracted, but I'd like to know the reasons behind its existence, maybe we're all missing something.

Angarsk8 commented May 3, 2017

I was wondering the same today. This is current implementation of the singleton/1 function:

singleton : a -> List a
singleton value =
  [value]

IMHO something that simple should not be abstracted, but I'd like to know the reasons behind its existence, maybe we're all missing something.

@roine

This comment has been minimized.

Show comment
Hide comment
@roine

roine May 3, 2017

Use case

List.map List.singleton [1,2]
>> [[1], [2]]

roine commented May 3, 2017

Use case

List.map List.singleton [1,2]
>> [[1], [2]]
@turboMaCk

This comment has been minimized.

Show comment
Hide comment
@turboMaCk

turboMaCk May 17, 2017

Contributor

It's useful. List.singleton is actually pure implementation for List as a Applicative.

It's useful for lifting function to List context. Unluckilly andMap is missing in core and can be found only in List.Extra.

Actual questions in my opinion are:

  • Does singleton make sense without andMap??
  • Should List in core implement applicative style since most folks don't use it?
Contributor

turboMaCk commented May 17, 2017

It's useful. List.singleton is actually pure implementation for List as a Applicative.

It's useful for lifting function to List context. Unluckilly andMap is missing in core and can be found only in List.Extra.

Actual questions in my opinion are:

  • Does singleton make sense without andMap??
  • Should List in core implement applicative style since most folks don't use it?
@lukewestby

This comment has been minimized.

Show comment
Hide comment
@lukewestby

lukewestby May 17, 2017

Member

Hey folks, this conversation belongs on elm-discuss or in slack. GitHub issues are for bugs, so as long as List.singleton works as advertised discussions about the name should be taken to the mailing list or slack.

Member

lukewestby commented May 17, 2017

Hey folks, this conversation belongs on elm-discuss or in slack. GitHub issues are for bugs, so as long as List.singleton works as advertised discussions about the name should be taken to the mailing list or slack.

@lukewestby lukewestby closed this May 17, 2017

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