Proposal: Add NonEmpty constructors to the Prelude
Edward Kmett
ekmett at gmail.com
Thu Dec 29 15:33:01 UTC 2016
I'm personally -1 on this proposal *at this time*. Adding these to the
footprint of Prelude means everybody who has written any data type with a
data constructor named :| breaks, every combinator named nonEmpty, NonEmpty
type or class... so we shouldn't do this lightly.
That said, Semigroup is slated to become a superclass of Monoid in 8.6 and
move into Prelude as part of the timeline on
https://prime.haskell.org/wiki/Libraries/Proposals
and Semigroup has sconcat as a member, which references NonEmpty. At that
point the case becomes much stronger, and the need to decide how to handle
sconcat for the Prelude acts as a forcing function for this decision.
On the other hand, we don't have many classes exported from Prelude
partially, but we do have them: Functor (<$), Read (readPrec,
readListPrec), Floating (log1p, expm1, etc.) come to mind as members we
avoid exporting from Prelude.
So while there is precedent for continuing to hide "messy" implementation
details, at that point the weight of simplicity of explanation may come
down on the other side of the argument.
With all that in mind I'm -1 if we're talking about adding this in 8.4, but
I'm largely neutral and maybe even weakly positive about it for 8.6 as part
of the larger Semigroup migration and would be happy to accept either the
hidden detail solution or a solution that dragged NonEmpty into base based
on community feedback.
-Edward
On Wed, Dec 28, 2016 at 2:39 PM, Yitzchak Gale <gale at sefer.org> wrote:
> In continuation of Simon Jakobi's proposal for a small
> incremental change to the Prelude to make it more
> conducive to partial-function-free programming,
>
> https://mail.haskell.org/pipermail/libraries/2016-December/027496.html
>
> and after some encouragement from the community on reddit,
> I propose adding the basic constructors of NonEmpty to
> the Prelude: nonEmpty, (:|), and the type constructor NonEmpty.
>
> In practice, users of NonEmpty will often still need a qualified
> import of Data.List.NonEmpty. But having the constructors
> available in the Prelude will make the use of NonEmpty more
> common, and will make programming without partial functions
> feel more natural and standard.
>
> Note: This proposal is separate from Simon's and should not
> interfere with the acceptance of Simon's. But it is related in
> that it attempts to achieve the same goals.
>
> Discussion period: Until the end of the discussion period of
> Simon's proposal.
>
> Thanks,
> Yitz
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20161229/3481000c/attachment.html>
More information about the Libraries
mailing list