Proposal: Add a splitBy / splitOn in Data.List

Vanessa McHale vanessa.mchale at iohk.io
Fri Nov 2 12:01:35 UTC 2018


cabal now has the ability to be used for
[scripting](https://github.com/haskell/cabal/pull/5483#issuecomment-409633079)
which I think addresses your use case (at least, it's easier than
forking base...).

On 11/2/18 6:38 AM, Elliot Cameron wrote:
> Despite these subtleties, I must confess I've often wanted to whip up
> a quick script and been frustrated that these functions are missing
> from base. For example using Haskell as a sed/awk alternative can be
> pleasant *if* the functions you need are in base. What's more, in many
> years I've only really wanted one or two versions of this.
>
> What if we added the most flexible of versions and included only that?
> This version would accept multicharacter delimiters, always throw them
> away, and always produce a new entry in the result for every
> occurrence of the delimiter. If you don't want the empty entries, you
> can filter. If you don't want leading, you can dropWhile. If you want
> the delimiters back, you can map. This seems like a nice trade-off for
> just being available in base.
>
> On Fri, Nov 2, 2018, 1:51 AM Edward Kmett <ekmett at gmail.com
> <mailto:ekmett at gmail.com> wrote:
>
>     The main thing that prevented it from going into base is the
>     number of subtleties about what precisely it means to properly
>     "split" something.
>
>     Most languages make fairly arbitrary calls on topics such as:
>
>     * Do you split on list elements (e.g. ',') or list of elements, so
>     you can multi-character delimiters ", "? What about multiple types
>     of thing that are all delimiters, e.g. any whitespace character?
>     * What do you do with the delimiters?
>     * What happens with runs of delimiters? 
>     * What about initial or final runs of delimiters (e.g. leading
>     spaces)?
>
>     The end result was that a split package was written by Brent
>     Yorgey back in 2008 or so that rather comprehensively covers the
>     design space, and it was incorporated into the Haskell Platform.
>
>     http://hackage.haskell.org/package/split-0.2.3.3/docs/Data-List-Split.html
>
>     -Edward
>
>     On Thu, Nov 1, 2018 at 1:34 PM Saurabh Nanda
>     <saurabhnanda at gmail.com <mailto:saurabhnanda at gmail.com>> wrote:
>
>         This has certainly been discussed before. A quick Google
>         search turned up the following past discussions:
>
>           * https://mail.haskell.org/pipermail/libraries/2006-July/005494.html
>           * https://mail.haskell.org/pipermail/libraries/2012-July/018228.html
>
>         Is there anything blocking this discussion & implementation?
>         Anything that can be done to unblock it?
>
>         -- Saurabh.
>
>         _______________________________________________
>         Libraries mailing list
>         Libraries at haskell.org <mailto:Libraries at haskell.org>
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>     _______________________________________________
>     Libraries mailing list
>     Libraries at haskell.org <mailto:Libraries at haskell.org>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- 



*Vanessa McHale*
Functional Compiler Engineer | Chicago, IL

Website: www.iohk.io <http://iohk.io>
Twitter: @vamchale
PGP Key ID: 4209B7B5

Input Output <http://iohk.io>

Twitter <https://twitter.com/InputOutputHK> Github
<https://github.com/input-output-hk> LinkedIn
<https://www.linkedin.com/company/input-output-global>


This e-mail and any file transmitted with it are confidential and
intended solely for the use of the recipient(s) to whom it is addressed.
Dissemination, distribution, and/or copying of the transmission by
anyone other than the intended recipient(s) is prohibited. If you have
received this transmission in error please notify IOHK immediately and
delete it from your system. E-mail transmissions cannot be guaranteed to
be secure or error free. We do not accept liability for any loss,
damage, or error arising from this transmission
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181102/12ecc542/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181102/12ecc542/attachment.sig>


More information about the Libraries mailing list