Proposal: unsnoc, unsafeInit and unsafeLast for the bytestring library
iridcode at gmail.com
Tue Apr 3 14:35:35 CEST 2012
I've never used these functions in my code. So I cannot judge their
usefulness. Having inspected your patch, I see the following points
1. The clarity of the code of Data.ByteString.unsnoc would profit from
using your 'unsafeInit and unsafeLast' functions.
2. It might well be that some other places could profit from your
'unsafeInit' and 'unsafeLast' functions; e.g., the 'init' and 'last'
functions. It would be great if you also updated other related
3. The implementation of Data.ByteString.Lazy.unsnoc is too strict in
my opinion. I would expect it to return 'Just
<combined-init-and-last-computation>', as soon as it has proven that
the ByteString is non-empty. To avoid unnecessary code duplication, it
might make sense to inline only the wrapper and let GHC decide what it
wants to do for the actual worker.
2012/4/2 Mikhail Vorozhtsov <mikhail.vorozhtsov at gmail.com>:
> I propose to add the missing counterparts of `uncons` and `unsafeHead/Tail`
> functions to the bytestring library.
> Discussion deadline: 2 weeks
> The patch is attached.
> Libraries mailing list
> Libraries at haskell.org
More information about the Libraries