Proposal: Add singleton function to Data.List module

Bryan Richter b at chreekat.net
Fri Aug 16 04:47:08 UTC 2019


On 8/16/19 4:17 AM, Carter Schonwald wrote:

> Hard -1, , i'm not seeing a useful high impact payoff
>
> plus its more verbose and adhoc than pure and more confusing than
> (:[])
>
> I actually initially thought this thread was about Type Singletons
> and or Proxy style apis using List as the term level form, it
> actually took me a few minutes of reading everyone's replies to
> disambiguate

If a value-level 'singleton' is confusing to anybody, I have really[1]
quite[2] terrible[3], in[4] fact[5] downright[6] awful[7] news[8]. :)

+1 to Data.List.singleton and Data.List.NonEmpty.singleton from me in
the peanut gallery. I agree with the sentiment that 'pure @ []' means
"side effect-free nondeterministic value", which is quite different
than meaning "a list with one element", and is therefore possibly more
ad hoc than using the well-established 'singleton'.

But I also joyfully assent to the decision of the CLC! Besides the
possibility for breakage (can we use head.hackage to get hard data
here?), I have not seen a single "technical", data-based argument from
either side. Even asking the proponents to provide technical
arguments, after all, is a subjective criterion.

With respectful acknowledgement of all positions taken,

-Bryan

[1]: https://hackage.haskell.org/package/bytestring/docs/Data-ByteString.html#v:singleton
[2]: https://hackage.haskell.org/package/containers/docs/Data-IntMap-Internal.html#v:singleton
[3]: https://hackage.haskell.org/package/text/docs/Data-Text.html#v:singleton
[4]: https://hackage.haskell.org/package/vector/docs/Data-Vector.html#v:singleton
[5]: https://hackage.haskell.org/package/unordered-containers/docs/Data-HashSet.html#v:singleton
[6]: https://hackage.haskell.org/package/lens/docs/Control-Lens-Internal-Deque.html#v:singleton
[7]: https://hackage.haskell.org/package/Cabal/docs/Distribution-Compat-DList.html#v:singleton
[8]: https://hackage.haskell.org/package/memory/docs/Data-ByteArray.html#v:singleton

p.s. I've intentionally chosen eight different packages, some of which
include a number of different 'singleton's!



More information about the Libraries mailing list