splitOn for Data.ByteString/Data.ByteString.Lazy
- Dominant language
- Haskell
- Stars
- 301
- Forks
- 144
- Avg merge
- 7d 22h
- Merged PRs (30d)
- 1
Description
As per http://stackoverflow.com/questions/1398322/split-bytestring-on-a-bytestring-instead-of-a-word8-or-char this is a commonly requested piece of functionality. Here is one possible implementation for Data.ByteString:
```
splitOn :: Str -> Str -> [Str]
splitOn needle haystack0 = go haystack0
where
l = length needle
breaker = breakSubstring needle -- save preprocessing
go s = let (pre, post) = breaker s
in pre : if null post
then []
else go (drop l post)
```
However, for lazy bytestrings, we will need an implementation of breakSubstring for them.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.