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

Already on GitHub? Sign in to your account

Remove listToMaybe #206

Closed
Martoon-00 opened this issue Nov 17, 2018 · 3 comments · Fixed by #258
Closed

Remove listToMaybe #206

Martoon-00 opened this issue Nov 17, 2018 · 3 comments · Fixed by #258
Labels
mistake reexport type:breaking Breaking change (removal, renaming, semantic change, etc.)
Milestone

Comments

@Martoon-00
Copy link
Member

It was funny to learn that we have yet another head here which is called listToMaybe.

I think this function isn't worth living as soon as its exact behavior is not totally clear from its name (what happens if a list has more than one element?)

@Martoon-00 Martoon-00 added mistake reexport type:breaking Breaking change (removal, renaming, semantic change, etc.) labels Nov 17, 2018
@dcastro
Copy link
Member

dcastro commented Apr 3, 2022

Agreed, but listToMaybe's type isn't exactly the same as head though...

  • listToMaybe :: [a] -> Maybe a
  • Universum.head :: NonEmpty a -> a
  • Universum.Unsafe.head :: [a] -> a

Maybe we should rename listToMaybe to headMaybe?

@Martoon-00
Copy link
Member Author

Ah, I rather compared listToMaybe to the entire family of head-like functions that we export (but my sentence was misleading).

Additionally to the functions you mentioned, there is safeHead :: Container t => t -> Maybe (Element a) that covers listToMaybe.


Maybe it's really worth having a renamed concrete headMaybe, this will solve the issue with uncertainty "what happens if the list las more than one element".

I personally think that having even 3 head-like functions is already almost too much, and we better go without [a] -> Maybe a variation.

@dcastro
Copy link
Member

dcastro commented Apr 4, 2022

there is safeHead

Ah right of course! Hackage's "search box" feature wasn't being very friendly 😅

I personally think that having even 3 head-like functions is already almost too much, and we better go without [a] -> Maybe a variation.

Absolutely, given that we have safeHead, I also vote for straight up deleting listToMaybe.

@dcastro dcastro added this to the v1.8.0 milestone Apr 7, 2022
DK318 added a commit that referenced this issue Apr 16, 2022
Problem: we export `listToMaybe` from `Data.Maybe`. It makes no sense
because we have `safeHead` in `Universum.Container` which does the same thing.

Solution: remove `listToMaybe` from export list.
@DK318 DK318 mentioned this issue Apr 16, 2022
9 tasks
DK318 added a commit that referenced this issue Apr 21, 2022
Problem: we export `listToMaybe` from `Data.Maybe`. It makes no sense
because we have `safeHead` in `Universum.Container` which does the same thing.

Solution: remove `listToMaybe` from export list.
gromakovsky pushed a commit that referenced this issue Apr 21, 2022
Problem: we export `listToMaybe` from `Data.Maybe`. It makes no sense
because we have `safeHead` in `Universum.Container` which does the same thing.

Solution: remove `listToMaybe` from export list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mistake reexport type:breaking Breaking change (removal, renaming, semantic change, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants