Proposal: add uncons (and unsnoc) to Data.List

Edward Kmett ekmett at
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.

While the viewL/viewR's out there all have their heritage in the Data.Seq /
fingertree usage.

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.


On Sun, Jul 20, 2014 at 12:07 AM, Henning Thielemann <
schlepptop at> 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:
> docs/Data-Sequence.html#v:viewl
> There is also:
> docs/Data-Map-Lazy.html#v:minView
> docs/Data-Set.html#v:minView
> But I am not bound to it.
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list