Skip to content

Instantly share code, notes, and snippets.

@dmjio
Last active December 4, 2020 07:06
Show Gist options
  • Save dmjio/46433d7f23737095a58b07a21453d197 to your computer and use it in GitHub Desktop.
Save dmjio/46433d7f23737095a58b07a21453d197 to your computer and use it in GitHub Desktop.
import qualified Data.ByteString as B
import Data.ByteString (ByteString)
splitOn' :: ByteString -> ByteString -> [ByteString]
splitOn' del bs | B.null bs = []
splitOn' del bs =
case B.breakSubstring del bs of
(ls, rest) ->
if B.null rest
then ls : mempty
else ls : splitOn' del (B.tail rest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment