Closed Martoon-00 closed 2 years ago
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
?
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.
there is
safeHead
Ah right of course! Hackage's "search box" feature wasn't being very friendly :sweat_smile:
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
.
It was funny to learn that we have yet another
head
here which is calledlistToMaybe
.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?)