Proposal: add uncons (and unsnoc) to Data.List
Edward Kmett
ekmett at gmail.com
Sun Jul 20 05:38:12 UTC 2014
I'd favor unsnoc and uncons over viewL / viewR as the type is a bit
different having no dedicated view data type, etc.
uncons seems by far more commonly reinvented name for the concept, being
used across bytestring, parsec, etc.
https://www.fpcomplete.com/hoogle?q=uncons&env=ghc-7.4.2-stable-13.09
While the viewL/viewR's out there all have their heritage in the Data.Seq /
fingertree usage.
https://www.fpcomplete.com/hoogle?q=viewl&env=ghc-7.4.2-stable-13.09
I tend to reserve using viewL / viewR for the dedicated data type variant,
as because the latter fits in a bit worse with other uses of Maybe but can
be ever so slightly more efficient due to the dedicated constructor I often
try to supply both.
Also a motivation for the uncons nomenclature is it preserves something
like symmetry between
`unfoldr uncons` and `foldr (:) []`.
It is a much easier to sell an uncons/unsnoc than to sell new data types
and a viewL/viewR to go with them, and it seems to me to be better to
reserve the latter names for folks who do want to supply such a beast.
-Edward
On Sun, Jul 20, 2014 at 12:07 AM, Henning Thielemann <
schlepptop at henning-thielemann.de> wrote:
> Am 20.07.2014 05:01, schrieb wren romano:
>
>
> Yes, uncons is a view, but I see no benefit in naming the function
>> after that fact— given that "uncons" is the standard/popular name, and
>> that we don't typically name any other views "viewFoo".
>>
>
> As I said, I chose the name according to Data.Sequence:
>
> http://hackage.haskell.org/package/containers-0.5.5.1/
> docs/Data-Sequence.html#v:viewl
>
>
> There is also:
> http://hackage.haskell.org/package/containers-0.5.5.1/
> docs/Data-Map-Lazy.html#v:minView
> http://hackage.haskell.org/package/containers-0.5.5.1/
> docs/Data-Set.html#v:minView
>
>
> But I am not bound to it.
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140720/f1d216e1/attachment.html>
More information about the Libraries
mailing list