aboutsummaryrefslogtreecommitdiff
path: root/tests/bkpregex/str-impls/Str/ByteString.hs
blob: cd49fedf090ae77ec84280bef23d94ca7b2a8c36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Str.ByteString(module Data.ByteString.Char8, module Str.ByteString) where

import Prelude hiding (length, null, splitAt)
import Data.ByteString.Char8
import Data.ByteString

type Str = ByteString

splits :: Str -> [(Str, Str)]
splits s = fmap (\n -> splitAt n s) [0..length s]

parts :: Str -> [[Str]]
parts s | null s    = [[]]
        | otherwise = do
            n <- [1..length s]
            let (l, r) = splitAt n s
            fmap (l:) (parts r)