{-# LANGUAGE CPP
            ,MultiParamTypeClasses
            ,FlexibleInstances
            ,TypeFamilies
            ,TypeSynonymInstances
            ,GeneralizedNewtypeDeriving #-}


{-
Copyright (C) 2007 John Goerzen <jgoerzen@complete.org>

All rights reserved.

For license and copyright information, see the file COPYRIGHT

-}

{- |
   Module     : Data.ListLike.CharString
   Copyright  : Copyright (C) 2007 John Goerzen
   License    : BSD3

   Maintainer : David Fox <dsf@seereason.com>, Andreas Abel
   Stability  : stable
   Portability: portable

Newtype wrapper for ByteString to enable a Char-based interface
Re-exported by "Data.ListLike".

Written by John Lato, jwlato\@gmail.com
-}

module Data.ListLike.CharString (
  CharString (..)
 ,CharStringLazy (..)
)

where

import Prelude hiding (length, head, last, null, tail, map, filter, concat,
                       any, lookup, init, all, foldl, foldr, foldl1, foldr1,
                       maximum, minimum, iterate, span, break, takeWhile,
                       dropWhile, reverse, zip, zipWith, sequence,
                       sequence_, mapM, mapM_, concatMap, and, or, sum,
                       product, repeat, replicate, cycle, take, drop,
                       splitAt, elem, notElem, unzip, lines, words,
                       unlines, unwords)
--import qualified Data.Foldable as F
import           Data.ListLike.Base
import           Data.ListLike.String
import           Data.ListLike.IO
import           Data.ListLike.FoldableLL
import           Data.Int
#if !MIN_VERSION_base(4,11,0)
import           Data.Semigroup (Semigroup(..))
#endif
import           Data.String (IsString(..))
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
--import qualified System.IO as IO
--import           Data.Word
import           Control.Arrow
import           GHC.Exts (IsList(..))

--------------------------------------------------
-- ByteString

-- | Newtype wrapper around Data.ByteString.Char8.ByteString,
--   this allows for ListLike instances with Char elements.
newtype CharString = CS { CharString -> ByteString
unCS :: BS.ByteString }
  deriving (ReadPrec [CharString]
ReadPrec CharString
Int -> ReadS CharString
ReadS [CharString]
(Int -> ReadS CharString)
-> ReadS [CharString]
-> ReadPrec CharString
-> ReadPrec [CharString]
-> Read CharString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CharString]
$creadListPrec :: ReadPrec [CharString]
readPrec :: ReadPrec CharString
$creadPrec :: ReadPrec CharString
readList :: ReadS [CharString]
$creadList :: ReadS [CharString]
readsPrec :: Int -> ReadS CharString
$creadsPrec :: Int -> ReadS CharString
Read, Int -> CharString -> ShowS
[CharString] -> ShowS
CharString -> String
(Int -> CharString -> ShowS)
-> (CharString -> String)
-> ([CharString] -> ShowS)
-> Show CharString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CharString] -> ShowS
$cshowList :: [CharString] -> ShowS
show :: CharString -> String
$cshow :: CharString -> String
showsPrec :: Int -> CharString -> ShowS
$cshowsPrec :: Int -> CharString -> ShowS
Show, CharString -> CharString -> Bool
(CharString -> CharString -> Bool)
-> (CharString -> CharString -> Bool) -> Eq CharString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CharString -> CharString -> Bool
$c/= :: CharString -> CharString -> Bool
== :: CharString -> CharString -> Bool
$c== :: CharString -> CharString -> Bool
Eq, Eq CharString
Eq CharString
-> (CharString -> CharString -> Ordering)
-> (CharString -> CharString -> Bool)
-> (CharString -> CharString -> Bool)
-> (CharString -> CharString -> Bool)
-> (CharString -> CharString -> Bool)
-> (CharString -> CharString -> CharString)
-> (CharString -> CharString -> CharString)
-> Ord CharString
CharString -> CharString -> Bool
CharString -> CharString -> Ordering
CharString -> CharString -> CharString
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CharString -> CharString -> CharString
$cmin :: CharString -> CharString -> CharString
max :: CharString -> CharString -> CharString
$cmax :: CharString -> CharString -> CharString
>= :: CharString -> CharString -> Bool
$c>= :: CharString -> CharString -> Bool
> :: CharString -> CharString -> Bool
$c> :: CharString -> CharString -> Bool
<= :: CharString -> CharString -> Bool
$c<= :: CharString -> CharString -> Bool
< :: CharString -> CharString -> Bool
$c< :: CharString -> CharString -> Bool
compare :: CharString -> CharString -> Ordering
$ccompare :: CharString -> CharString -> Ordering
Ord, NonEmpty CharString -> CharString
CharString -> CharString -> CharString
(CharString -> CharString -> CharString)
-> (NonEmpty CharString -> CharString)
-> (forall b. Integral b => b -> CharString -> CharString)
-> Semigroup CharString
forall b. Integral b => b -> CharString -> CharString
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b. Integral b => b -> CharString -> CharString
$cstimes :: forall b. Integral b => b -> CharString -> CharString
sconcat :: NonEmpty CharString -> CharString
$csconcat :: NonEmpty CharString -> CharString
<> :: CharString -> CharString -> CharString
$c<> :: CharString -> CharString -> CharString
Semigroup, Semigroup CharString
CharString
Semigroup CharString
-> CharString
-> (CharString -> CharString -> CharString)
-> ([CharString] -> CharString)
-> Monoid CharString
[CharString] -> CharString
CharString -> CharString -> CharString
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [CharString] -> CharString
$cmconcat :: [CharString] -> CharString
mappend :: CharString -> CharString -> CharString
$cmappend :: CharString -> CharString -> CharString
mempty :: CharString
$cmempty :: CharString
Monoid)

instance FoldableLL CharString Char where
    foldl :: forall a. (a -> Char -> a) -> a -> CharString -> a
foldl a -> Char -> a
f a
i0  CharString
ls = (a -> Char -> a) -> a -> ByteString -> a
forall a. (a -> Char -> a) -> a -> ByteString -> a
BS.foldl a -> Char -> a
f a
i0 (CharString -> ByteString
unCS CharString
ls)
    foldl' :: forall a. (a -> Char -> a) -> a -> CharString -> a
foldl' a -> Char -> a
f a
i0 CharString
ls = (a -> Char -> a) -> a -> ByteString -> a
forall a. (a -> Char -> a) -> a -> ByteString -> a
BS.foldl' a -> Char -> a
f a
i0 (CharString -> ByteString
unCS CharString
ls)
    foldl1 :: (Char -> Char -> Char) -> CharString -> Char
foldl1 Char -> Char -> Char
f    CharString
ls = (Char -> Char -> Char) -> ByteString -> Char
BS.foldl1 Char -> Char -> Char
f (CharString -> ByteString
unCS CharString
ls)
    foldr :: forall b. (Char -> b -> b) -> b -> CharString -> b
foldr Char -> b -> b
f b
i0  CharString
ls = (Char -> b -> b) -> b -> ByteString -> b
forall a. (Char -> a -> a) -> a -> ByteString -> a
BS.foldr Char -> b -> b
f b
i0 (CharString -> ByteString
unCS CharString
ls)
    foldr1 :: (Char -> Char -> Char) -> CharString -> Char
foldr1 Char -> Char -> Char
f    CharString
ls = (Char -> Char -> Char) -> ByteString -> Char
BS.foldr1 Char -> Char -> Char
f (CharString -> ByteString
unCS CharString
ls)

instance IsList CharString where
  type Item CharString = Char
  toList :: CharString -> [Item CharString]
toList = ByteString -> String
BS.unpack (ByteString -> String)
-> (CharString -> ByteString) -> CharString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
  fromList :: [Item CharString] -> CharString
fromList = ByteString -> CharString
CS (ByteString -> CharString)
-> (String -> ByteString) -> String -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
BS.pack

instance ListLike CharString Char where
    empty :: CharString
empty = ByteString -> CharString
CS ByteString
BS.empty
    singleton :: Char -> CharString
singleton = ByteString -> CharString
CS (ByteString -> CharString)
-> (Char -> ByteString) -> Char -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString
BS.singleton
    cons :: Char -> CharString -> CharString
cons Char
x CharString
l = ByteString -> CharString
CS (Char -> ByteString -> ByteString
BS.cons Char
x (CharString -> ByteString
unCS CharString
l))
    snoc :: CharString -> Char -> CharString
snoc CharString
l Char
x = ByteString -> CharString
CS (ByteString -> Char -> ByteString
BS.snoc (CharString -> ByteString
unCS CharString
l) Char
x)
    append :: CharString -> CharString -> CharString
append CharString
l CharString
r = ByteString -> CharString
CS (ByteString -> CharString) -> ByteString -> CharString
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString -> ByteString
BS.append (CharString -> ByteString
unCS CharString
l) (CharString -> ByteString
unCS CharString
r)
    head :: CharString -> Char
head = ByteString -> Char
BS.head (ByteString -> Char)
-> (CharString -> ByteString) -> CharString -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    last :: CharString -> Char
last = ByteString -> Char
BS.last (ByteString -> Char)
-> (CharString -> ByteString) -> CharString -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    tail :: CharString -> CharString
tail = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BS.tail (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    init :: CharString -> CharString
init = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BS.init (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    null :: CharString -> Bool
null = ByteString -> Bool
BS.null (ByteString -> Bool)
-> (CharString -> ByteString) -> CharString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    length :: CharString -> Int
length = Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int) -> (CharString -> Int) -> CharString -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
BS.length (ByteString -> Int)
-> (CharString -> ByteString) -> CharString -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    -- map = BS.map
    rigidMap :: (Char -> Char) -> CharString -> CharString
rigidMap Char -> Char
f = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> ByteString -> ByteString
BS.map Char -> Char
f (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    reverse :: CharString -> CharString
reverse = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BS.reverse (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    --intersperse = BS.intersperse
    concat :: forall full'. ListLike full' CharString => full' -> CharString
concat = ByteString -> CharString
CS (ByteString -> CharString)
-> (full' -> ByteString) -> full' -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ByteString] -> ByteString
BS.concat ([ByteString] -> ByteString)
-> (full' -> [ByteString]) -> full' -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CharString -> ByteString) -> [CharString] -> [ByteString]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map CharString -> ByteString
unCS ([CharString] -> [ByteString])
-> (full' -> [CharString]) -> full' -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. full' -> [CharString]
forall l. IsList l => l -> [Item l]
toList
    --concatMap = BS.concatMap
    rigidConcatMap :: (Char -> CharString) -> CharString -> CharString
rigidConcatMap Char -> CharString
f = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> ByteString) -> ByteString -> ByteString
BS.concatMap (CharString -> ByteString
unCS (CharString -> ByteString)
-> (Char -> CharString) -> Char -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> CharString
f) (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    any :: (Char -> Bool) -> CharString -> Bool
any Char -> Bool
p = (Char -> Bool) -> ByteString -> Bool
BS.any Char -> Bool
p (ByteString -> Bool)
-> (CharString -> ByteString) -> CharString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    all :: (Char -> Bool) -> CharString -> Bool
all Char -> Bool
p = (Char -> Bool) -> ByteString -> Bool
BS.all Char -> Bool
p (ByteString -> Bool)
-> (CharString -> ByteString) -> CharString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    maximum :: Ord Char => CharString -> Char
maximum = ByteString -> Char
BS.maximum (ByteString -> Char)
-> (CharString -> ByteString) -> CharString -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    minimum :: Ord Char => CharString -> Char
minimum = ByteString -> Char
BS.minimum (ByteString -> Char)
-> (CharString -> ByteString) -> CharString -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    replicate :: Int -> Char -> CharString
replicate Int
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (Char -> ByteString) -> Char -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Char -> ByteString
BS.replicate (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
    take :: Int -> CharString -> CharString
take Int
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> ByteString
BS.take (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    drop :: Int -> CharString -> CharString
drop Int
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> ByteString
BS.drop (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    splitAt :: Int -> CharString -> (CharString, CharString)
splitAt Int
i = (ByteString -> CharString
CS (ByteString -> CharString)
-> (ByteString -> CharString)
-> (ByteString, ByteString)
-> (CharString, CharString)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharString
CS) ((ByteString, ByteString) -> (CharString, CharString))
-> (CharString -> (ByteString, ByteString))
-> CharString
-> (CharString, CharString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> (ByteString, ByteString)
BS.splitAt (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> (ByteString, ByteString))
-> (CharString -> ByteString)
-> CharString
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    takeWhile :: (Char -> Bool) -> CharString -> CharString
takeWhile Char -> Bool
p = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BS.takeWhile Char -> Bool
p (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    dropWhile :: (Char -> Bool) -> CharString -> CharString
dropWhile Char -> Bool
p = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BS.dropWhile Char -> Bool
p (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    span :: (Char -> Bool) -> CharString -> (CharString, CharString)
span Char -> Bool
p  = (ByteString -> CharString
CS (ByteString -> CharString)
-> (ByteString -> CharString)
-> (ByteString, ByteString)
-> (CharString, CharString)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharString
CS) ((ByteString, ByteString) -> (CharString, CharString))
-> (CharString -> (ByteString, ByteString))
-> CharString
-> (CharString, CharString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span Char -> Bool
p (ByteString -> (ByteString, ByteString))
-> (CharString -> ByteString)
-> CharString
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    break :: (Char -> Bool) -> CharString -> (CharString, CharString)
break Char -> Bool
p = (ByteString -> CharString
CS (ByteString -> CharString)
-> (ByteString -> CharString)
-> (ByteString, ByteString)
-> (CharString, CharString)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharString
CS) ((ByteString, ByteString) -> (CharString, CharString))
-> (CharString -> (ByteString, ByteString))
-> CharString
-> (CharString, CharString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BS.break Char -> Bool
p (ByteString -> (ByteString, ByteString))
-> (CharString -> ByteString)
-> CharString
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    group :: forall full'.
(ListLike full' CharString, Eq Char) =>
CharString -> full'
group = [CharString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharString] -> full')
-> (CharString -> [CharString]) -> CharString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharString) -> [ByteString] -> [CharString]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharString
CS ([ByteString] -> [CharString])
-> (CharString -> [ByteString]) -> CharString -> [CharString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.group (ByteString -> [ByteString])
-> (CharString -> ByteString) -> CharString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    inits :: forall full'. ListLike full' CharString => CharString -> full'
inits = [CharString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharString] -> full')
-> (CharString -> [CharString]) -> CharString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharString) -> [ByteString] -> [CharString]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharString
CS ([ByteString] -> [CharString])
-> (CharString -> [ByteString]) -> CharString -> [CharString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.inits (ByteString -> [ByteString])
-> (CharString -> ByteString) -> CharString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    tails :: forall full'. ListLike full' CharString => CharString -> full'
tails = [CharString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharString] -> full')
-> (CharString -> [CharString]) -> CharString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharString) -> [ByteString] -> [CharString]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharString
CS ([ByteString] -> [CharString])
-> (CharString -> [ByteString]) -> CharString -> [CharString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.tails (ByteString -> [ByteString])
-> (CharString -> ByteString) -> CharString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    isPrefixOf :: Eq Char => CharString -> CharString -> Bool
isPrefixOf CharString
p CharString
f = ByteString -> ByteString -> Bool
BS.isPrefixOf (CharString -> ByteString
unCS CharString
p) (CharString -> ByteString
unCS CharString
f)
    --isSuffixOf = BS.isSuffixOf
    --isInfixOf = BS.isInfixOf
    elem :: Eq Char => Char -> CharString -> Bool
elem Char
x = Char -> ByteString -> Bool
BS.elem Char
x (ByteString -> Bool)
-> (CharString -> ByteString) -> CharString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    notElem :: Eq Char => Char -> CharString -> Bool
notElem Char
x = Char -> ByteString -> Bool
BS.notElem Char
x (ByteString -> Bool)
-> (CharString -> ByteString) -> CharString -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    find :: (Char -> Bool) -> CharString -> Maybe Char
find Char -> Bool
p = (Char -> Bool) -> ByteString -> Maybe Char
BS.find Char -> Bool
p (ByteString -> Maybe Char)
-> (CharString -> ByteString) -> CharString -> Maybe Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    filter :: (Char -> Bool) -> CharString -> CharString
filter Char -> Bool
p = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BS.filter Char -> Bool
p (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    --partition = BS.partition
    index :: CharString -> Int -> Char
index CharString
l Int
i = ByteString -> Int -> Char
BS.index (CharString -> ByteString
unCS CharString
l) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
    elemIndex :: Eq Char => Char -> CharString -> Maybe Int
elemIndex Char
i = Char -> ByteString -> Maybe Int
BS.elemIndex Char
i  (ByteString -> Maybe Int)
-> (CharString -> ByteString) -> CharString -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    --elemIndices x = fromList . L.map fromIntegral . BS.elemIndices x
    findIndex :: (Char -> Bool) -> CharString -> Maybe Int
findIndex Char -> Bool
f = (Char -> Bool) -> ByteString -> Maybe Int
BS.findIndex Char -> Bool
f (ByteString -> Maybe Int)
-> (CharString -> ByteString) -> CharString -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    --findIndices x = fromList . L.map fromIntegral . BS.findIndices x
    --sequence = BS.sequence
    --mapM = BS.mapM
    --mapM_ = BS.mapM_
    --nub = BS.nub
    --delete = BS.delete
    --deleteFirsts = BS.deleteFirsts
    --union = BS.union
    --intersect = BS.intersect
    --sort = BS.sort
    --insert = BS.insert
    --toList = BS.unpack . unCS
    --fromList = CS . BS.pack
    --fromListLike = fromList . toList
    --nubBy = BS.nubBy
    --deleteBy = BS.deleteBy
    --deleteFirstsBy = BS.deleteFirstsBy
    --unionBy = BS.unionBy
    --intersectBy = BS.intersectBy
    -- BS.groupBy is broken. groupBy f = fromList . BS.groupBy f
    -- the below works on ghc but generates a type error on hugs
    -- groupBy func = map fromList . L.groupBy func . toList
    --sortBy = BS.sortBy
    --insertBy = BS.insertBy
    genericLength :: forall a. Num a => CharString -> a
genericLength = Integer -> a
forall a. Num a => Integer -> a
fromInteger (Integer -> a) -> (CharString -> Integer) -> CharString -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer) -> (CharString -> Int) -> CharString -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
BS.length (ByteString -> Int)
-> (CharString -> ByteString) -> CharString -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    genericTake :: forall b. Integral b => b -> CharString -> CharString
genericTake a
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> ByteString
BS.take (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    genericDrop :: forall b. Integral b => b -> CharString -> CharString
genericDrop a
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (CharString -> ByteString) -> CharString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> ByteString
BS.drop (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> ByteString)
-> (CharString -> ByteString) -> CharString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    genericSplitAt :: forall a. Integral a => a -> CharString -> (CharString, CharString)
genericSplitAt a
i = (ByteString -> CharString
CS (ByteString -> CharString)
-> (ByteString -> CharString)
-> (ByteString, ByteString)
-> (CharString, CharString)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharString
CS) ((ByteString, ByteString) -> (CharString, CharString))
-> (CharString -> (ByteString, ByteString))
-> CharString
-> (CharString, CharString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ByteString -> (ByteString, ByteString)
BS.splitAt (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> (ByteString, ByteString))
-> (CharString -> ByteString)
-> CharString
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    genericReplicate :: forall a. Integral a => a -> Char -> CharString
genericReplicate a
i = ByteString -> CharString
CS (ByteString -> CharString)
-> (Char -> ByteString) -> Char -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Char -> ByteString
BS.replicate (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)

instance ListLikeIO CharString Char where
    hGetLine :: Handle -> IO CharString
hGetLine Handle
h = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS (IO ByteString -> IO CharString) -> IO ByteString -> IO CharString
forall a b. (a -> b) -> a -> b
$ Handle -> IO ByteString
BS.hGetLine Handle
h
    hGetContents :: Handle -> IO CharString
hGetContents = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS (IO ByteString -> IO CharString)
-> (Handle -> IO ByteString) -> Handle -> IO CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> IO ByteString
BS.hGetContents
    hGet :: Handle -> Int -> IO CharString
hGet Handle
h Int
n = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS (IO ByteString -> IO CharString) -> IO ByteString -> IO CharString
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO ByteString
BS.hGet Handle
h Int
n
    hGetNonBlocking :: Handle -> Int -> IO CharString
hGetNonBlocking Handle
h Int
n = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS (IO ByteString -> IO CharString) -> IO ByteString -> IO CharString
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO ByteString
BS.hGetNonBlocking Handle
h Int
n
    hPutStr :: Handle -> CharString -> IO ()
hPutStr Handle
h = Handle -> ByteString -> IO ()
BS.hPut Handle
h (ByteString -> IO ())
-> (CharString -> ByteString) -> CharString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    --hPutStrLn = BS.hPutStrLn
    getLine :: IO CharString
getLine = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS IO ByteString
BS.getLine
    getContents :: IO CharString
getContents = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS IO ByteString
BS.getContents
    putStr :: CharString -> IO ()
putStr = ByteString -> IO ()
BS.putStr (ByteString -> IO ())
-> (CharString -> ByteString) -> CharString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    putStrLn :: CharString -> IO ()
putStrLn = ByteString -> IO ()
BS.putStrLn (ByteString -> IO ())
-> (CharString -> ByteString) -> CharString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    interact :: (CharString -> CharString) -> IO ()
interact CharString -> CharString
f = (ByteString -> ByteString) -> IO ()
BS.interact (CharString -> ByteString
unCS (CharString -> ByteString)
-> (ByteString -> CharString) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> CharString
f (CharString -> CharString)
-> (ByteString -> CharString) -> ByteString -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> CharString
CS)
    readFile :: String -> IO CharString
readFile = (ByteString -> CharString) -> IO ByteString -> IO CharString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharString
CS (IO ByteString -> IO CharString)
-> (String -> IO ByteString) -> String -> IO CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ByteString
BS.readFile
    writeFile :: String -> CharString -> IO ()
writeFile String
fp = String -> ByteString -> IO ()
BS.writeFile String
fp (ByteString -> IO ())
-> (CharString -> ByteString) -> CharString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS
    appendFile :: String -> CharString -> IO ()
appendFile String
fp = String -> ByteString -> IO ()
BS.appendFile String
fp (ByteString -> IO ())
-> (CharString -> ByteString) -> CharString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS

instance IsString CharString where
    fromString :: String -> CharString
fromString = ByteString -> CharString
CS (ByteString -> CharString)
-> (String -> ByteString) -> String -> CharString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
BS.pack

instance StringLike CharString where
    toString :: CharString -> String
toString = ByteString -> String
BS.unpack (ByteString -> String)
-> (CharString -> ByteString) -> CharString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharString -> ByteString
unCS

--------------------------------------------------
-- ByteString.Lazy

-- | Newtype wrapper around Data.ByteString.Lazy.Char8.ByteString,
--   this allows for ListLike instances with Char elements.
newtype CharStringLazy = CSL { CharStringLazy -> ByteString
unCSL :: BSL.ByteString }
  deriving (ReadPrec [CharStringLazy]
ReadPrec CharStringLazy
Int -> ReadS CharStringLazy
ReadS [CharStringLazy]
(Int -> ReadS CharStringLazy)
-> ReadS [CharStringLazy]
-> ReadPrec CharStringLazy
-> ReadPrec [CharStringLazy]
-> Read CharStringLazy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CharStringLazy]
$creadListPrec :: ReadPrec [CharStringLazy]
readPrec :: ReadPrec CharStringLazy
$creadPrec :: ReadPrec CharStringLazy
readList :: ReadS [CharStringLazy]
$creadList :: ReadS [CharStringLazy]
readsPrec :: Int -> ReadS CharStringLazy
$creadsPrec :: Int -> ReadS CharStringLazy
Read, Int -> CharStringLazy -> ShowS
[CharStringLazy] -> ShowS
CharStringLazy -> String
(Int -> CharStringLazy -> ShowS)
-> (CharStringLazy -> String)
-> ([CharStringLazy] -> ShowS)
-> Show CharStringLazy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CharStringLazy] -> ShowS
$cshowList :: [CharStringLazy] -> ShowS
show :: CharStringLazy -> String
$cshow :: CharStringLazy -> String
showsPrec :: Int -> CharStringLazy -> ShowS
$cshowsPrec :: Int -> CharStringLazy -> ShowS
Show, CharStringLazy -> CharStringLazy -> Bool
(CharStringLazy -> CharStringLazy -> Bool)
-> (CharStringLazy -> CharStringLazy -> Bool) -> Eq CharStringLazy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CharStringLazy -> CharStringLazy -> Bool
$c/= :: CharStringLazy -> CharStringLazy -> Bool
== :: CharStringLazy -> CharStringLazy -> Bool
$c== :: CharStringLazy -> CharStringLazy -> Bool
Eq, Eq CharStringLazy
Eq CharStringLazy
-> (CharStringLazy -> CharStringLazy -> Ordering)
-> (CharStringLazy -> CharStringLazy -> Bool)
-> (CharStringLazy -> CharStringLazy -> Bool)
-> (CharStringLazy -> CharStringLazy -> Bool)
-> (CharStringLazy -> CharStringLazy -> Bool)
-> (CharStringLazy -> CharStringLazy -> CharStringLazy)
-> (CharStringLazy -> CharStringLazy -> CharStringLazy)
-> Ord CharStringLazy
CharStringLazy -> CharStringLazy -> Bool
CharStringLazy -> CharStringLazy -> Ordering
CharStringLazy -> CharStringLazy -> CharStringLazy
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CharStringLazy -> CharStringLazy -> CharStringLazy
$cmin :: CharStringLazy -> CharStringLazy -> CharStringLazy
max :: CharStringLazy -> CharStringLazy -> CharStringLazy
$cmax :: CharStringLazy -> CharStringLazy -> CharStringLazy
>= :: CharStringLazy -> CharStringLazy -> Bool
$c>= :: CharStringLazy -> CharStringLazy -> Bool
> :: CharStringLazy -> CharStringLazy -> Bool
$c> :: CharStringLazy -> CharStringLazy -> Bool
<= :: CharStringLazy -> CharStringLazy -> Bool
$c<= :: CharStringLazy -> CharStringLazy -> Bool
< :: CharStringLazy -> CharStringLazy -> Bool
$c< :: CharStringLazy -> CharStringLazy -> Bool
compare :: CharStringLazy -> CharStringLazy -> Ordering
$ccompare :: CharStringLazy -> CharStringLazy -> Ordering
Ord, NonEmpty CharStringLazy -> CharStringLazy
CharStringLazy -> CharStringLazy -> CharStringLazy
(CharStringLazy -> CharStringLazy -> CharStringLazy)
-> (NonEmpty CharStringLazy -> CharStringLazy)
-> (forall b. Integral b => b -> CharStringLazy -> CharStringLazy)
-> Semigroup CharStringLazy
forall b. Integral b => b -> CharStringLazy -> CharStringLazy
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b. Integral b => b -> CharStringLazy -> CharStringLazy
$cstimes :: forall b. Integral b => b -> CharStringLazy -> CharStringLazy
sconcat :: NonEmpty CharStringLazy -> CharStringLazy
$csconcat :: NonEmpty CharStringLazy -> CharStringLazy
<> :: CharStringLazy -> CharStringLazy -> CharStringLazy
$c<> :: CharStringLazy -> CharStringLazy -> CharStringLazy
Semigroup, Semigroup CharStringLazy
CharStringLazy
Semigroup CharStringLazy
-> CharStringLazy
-> (CharStringLazy -> CharStringLazy -> CharStringLazy)
-> ([CharStringLazy] -> CharStringLazy)
-> Monoid CharStringLazy
[CharStringLazy] -> CharStringLazy
CharStringLazy -> CharStringLazy -> CharStringLazy
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [CharStringLazy] -> CharStringLazy
$cmconcat :: [CharStringLazy] -> CharStringLazy
mappend :: CharStringLazy -> CharStringLazy -> CharStringLazy
$cmappend :: CharStringLazy -> CharStringLazy -> CharStringLazy
mempty :: CharStringLazy
$cmempty :: CharStringLazy
Monoid)

instance FoldableLL CharStringLazy Char where
    foldl :: forall a. (a -> Char -> a) -> a -> CharStringLazy -> a
foldl a -> Char -> a
f a
i0  CharStringLazy
ls = (a -> Char -> a) -> a -> ByteString -> a
forall a. (a -> Char -> a) -> a -> ByteString -> a
BSL.foldl a -> Char -> a
f a
i0 (CharStringLazy -> ByteString
unCSL CharStringLazy
ls)
    foldl' :: forall a. (a -> Char -> a) -> a -> CharStringLazy -> a
foldl' a -> Char -> a
f a
i0 CharStringLazy
ls = (a -> Char -> a) -> a -> ByteString -> a
forall a. (a -> Char -> a) -> a -> ByteString -> a
BSL.foldl' a -> Char -> a
f a
i0 (CharStringLazy -> ByteString
unCSL CharStringLazy
ls)
    foldl1 :: (Char -> Char -> Char) -> CharStringLazy -> Char
foldl1 Char -> Char -> Char
f    CharStringLazy
ls = (Char -> Char -> Char) -> ByteString -> Char
BSL.foldl1 Char -> Char -> Char
f (CharStringLazy -> ByteString
unCSL CharStringLazy
ls)
    foldr :: forall b. (Char -> b -> b) -> b -> CharStringLazy -> b
foldr Char -> b -> b
f b
i0  CharStringLazy
ls = (Char -> b -> b) -> b -> ByteString -> b
forall a. (Char -> a -> a) -> a -> ByteString -> a
BSL.foldr Char -> b -> b
f b
i0 (CharStringLazy -> ByteString
unCSL CharStringLazy
ls)
    foldr1 :: (Char -> Char -> Char) -> CharStringLazy -> Char
foldr1 Char -> Char -> Char
f    CharStringLazy
ls = (Char -> Char -> Char) -> ByteString -> Char
BSL.foldr1 Char -> Char -> Char
f (CharStringLazy -> ByteString
unCSL CharStringLazy
ls)

mi64toi :: Maybe Int64 -> Maybe Int
mi64toi :: Maybe Int64 -> Maybe Int
mi64toi Maybe Int64
Nothing = Maybe Int
forall a. Maybe a
Nothing
mi64toi (Just Int64
x) = Int -> Maybe Int
forall a. a -> Maybe a
Just (Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
x)

instance IsList CharStringLazy where
  type Item CharStringLazy = Char
  toList :: CharStringLazy -> [Item CharStringLazy]
toList = ByteString -> String
BSL.unpack (ByteString -> String)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
  fromList :: [Item CharStringLazy] -> CharStringLazy
fromList = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (String -> ByteString) -> String -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
BSL.pack

instance ListLike CharStringLazy Char where
    empty :: CharStringLazy
empty = ByteString -> CharStringLazy
CSL ByteString
BSL.empty
    singleton :: Char -> CharStringLazy
singleton = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (Char -> ByteString) -> Char -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString
BSL.singleton
    cons :: Char -> CharStringLazy -> CharStringLazy
cons Char
x CharStringLazy
l = ByteString -> CharStringLazy
CSL (Char -> ByteString -> ByteString
BSL.cons Char
x (CharStringLazy -> ByteString
unCSL CharStringLazy
l))
    snoc :: CharStringLazy -> Char -> CharStringLazy
snoc CharStringLazy
l Char
x = ByteString -> CharStringLazy
CSL (ByteString -> Char -> ByteString
BSL.snoc (CharStringLazy -> ByteString
unCSL CharStringLazy
l) Char
x)
    append :: CharStringLazy -> CharStringLazy -> CharStringLazy
append CharStringLazy
l CharStringLazy
r = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy) -> ByteString -> CharStringLazy
forall a b. (a -> b) -> a -> b
$ ByteString -> ByteString -> ByteString
BSL.append (CharStringLazy -> ByteString
unCSL CharStringLazy
l) (CharStringLazy -> ByteString
unCSL CharStringLazy
r)
    head :: CharStringLazy -> Char
head = ByteString -> Char
BSL.head (ByteString -> Char)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    last :: CharStringLazy -> Char
last = ByteString -> Char
BSL.last (ByteString -> Char)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    tail :: CharStringLazy -> CharStringLazy
tail = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.tail (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    init :: CharStringLazy -> CharStringLazy
init = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.init (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    null :: CharStringLazy -> Bool
null = ByteString -> Bool
BSL.null (ByteString -> Bool)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    length :: CharStringLazy -> Int
length = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int)
-> (CharStringLazy -> Int64) -> CharStringLazy -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int64
BSL.length (ByteString -> Int64)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    -- map = BSL.map
    rigidMap :: (Char -> Char) -> CharStringLazy -> CharStringLazy
rigidMap Char -> Char
f = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> ByteString -> ByteString
BSL.map Char -> Char
f (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    reverse :: CharStringLazy -> CharStringLazy
reverse = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.reverse (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    --intersperse = BSL.intersperse
    concat :: forall full'.
ListLike full' CharStringLazy =>
full' -> CharStringLazy
concat = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (full' -> ByteString) -> full' -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ByteString] -> ByteString
BSL.concat ([ByteString] -> ByteString)
-> (full' -> [ByteString]) -> full' -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CharStringLazy -> ByteString) -> [CharStringLazy] -> [ByteString]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map CharStringLazy -> ByteString
unCSL ([CharStringLazy] -> [ByteString])
-> (full' -> [CharStringLazy]) -> full' -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. full' -> [CharStringLazy]
forall l. IsList l => l -> [Item l]
toList
    --concatMap = BSL.concatMap
    rigidConcatMap :: (Char -> CharStringLazy) -> CharStringLazy -> CharStringLazy
rigidConcatMap Char -> CharStringLazy
f = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> ByteString) -> ByteString -> ByteString
BSL.concatMap (CharStringLazy -> ByteString
unCSL (CharStringLazy -> ByteString)
-> (Char -> CharStringLazy) -> Char -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> CharStringLazy
f) (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    any :: (Char -> Bool) -> CharStringLazy -> Bool
any Char -> Bool
p = (Char -> Bool) -> ByteString -> Bool
BSL.any Char -> Bool
p (ByteString -> Bool)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    all :: (Char -> Bool) -> CharStringLazy -> Bool
all Char -> Bool
p = (Char -> Bool) -> ByteString -> Bool
BSL.all Char -> Bool
p (ByteString -> Bool)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    maximum :: Ord Char => CharStringLazy -> Char
maximum = ByteString -> Char
BSL.maximum (ByteString -> Char)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    minimum :: Ord Char => CharStringLazy -> Char
minimum = ByteString -> Char
BSL.minimum (ByteString -> Char)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    replicate :: Int -> Char -> CharStringLazy
replicate Int
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (Char -> ByteString) -> Char -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Char -> ByteString
BSL.replicate (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
    take :: Int -> CharStringLazy -> CharStringLazy
take Int
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> ByteString
BSL.take (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    drop :: Int -> CharStringLazy -> CharStringLazy
drop Int
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> ByteString
BSL.drop (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    splitAt :: Int -> CharStringLazy -> (CharStringLazy, CharStringLazy)
splitAt Int
i = (ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (ByteString -> CharStringLazy)
-> (ByteString, ByteString)
-> (CharStringLazy, CharStringLazy)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharStringLazy
CSL) ((ByteString, ByteString) -> (CharStringLazy, CharStringLazy))
-> (CharStringLazy -> (ByteString, ByteString))
-> CharStringLazy
-> (CharStringLazy, CharStringLazy)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> (ByteString, ByteString)
BSL.splitAt (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) (ByteString -> (ByteString, ByteString))
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    takeWhile :: (Char -> Bool) -> CharStringLazy -> CharStringLazy
takeWhile Char -> Bool
p = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BSL.takeWhile Char -> Bool
p (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    dropWhile :: (Char -> Bool) -> CharStringLazy -> CharStringLazy
dropWhile Char -> Bool
p = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BSL.dropWhile Char -> Bool
p (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    span :: (Char -> Bool)
-> CharStringLazy -> (CharStringLazy, CharStringLazy)
span Char -> Bool
p  = (ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (ByteString -> CharStringLazy)
-> (ByteString, ByteString)
-> (CharStringLazy, CharStringLazy)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharStringLazy
CSL) ((ByteString, ByteString) -> (CharStringLazy, CharStringLazy))
-> (CharStringLazy -> (ByteString, ByteString))
-> CharStringLazy
-> (CharStringLazy, CharStringLazy)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BSL.span Char -> Bool
p (ByteString -> (ByteString, ByteString))
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    break :: (Char -> Bool)
-> CharStringLazy -> (CharStringLazy, CharStringLazy)
break Char -> Bool
p = (ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (ByteString -> CharStringLazy)
-> (ByteString, ByteString)
-> (CharStringLazy, CharStringLazy)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharStringLazy
CSL) ((ByteString, ByteString) -> (CharStringLazy, CharStringLazy))
-> (CharStringLazy -> (ByteString, ByteString))
-> CharStringLazy
-> (CharStringLazy, CharStringLazy)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> (ByteString, ByteString)
BSL.break Char -> Bool
p (ByteString -> (ByteString, ByteString))
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    group :: forall full'.
(ListLike full' CharStringLazy, Eq Char) =>
CharStringLazy -> full'
group = [CharStringLazy] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharStringLazy] -> full')
-> (CharStringLazy -> [CharStringLazy]) -> CharStringLazy -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharStringLazy) -> [ByteString] -> [CharStringLazy]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharStringLazy
CSL ([ByteString] -> [CharStringLazy])
-> (CharStringLazy -> [ByteString])
-> CharStringLazy
-> [CharStringLazy]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.group (ByteString -> [ByteString])
-> (CharStringLazy -> ByteString) -> CharStringLazy -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    inits :: forall full'.
ListLike full' CharStringLazy =>
CharStringLazy -> full'
inits = [CharStringLazy] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharStringLazy] -> full')
-> (CharStringLazy -> [CharStringLazy]) -> CharStringLazy -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharStringLazy) -> [ByteString] -> [CharStringLazy]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharStringLazy
CSL ([ByteString] -> [CharStringLazy])
-> (CharStringLazy -> [ByteString])
-> CharStringLazy
-> [CharStringLazy]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.inits (ByteString -> [ByteString])
-> (CharStringLazy -> ByteString) -> CharStringLazy -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    tails :: forall full'.
ListLike full' CharStringLazy =>
CharStringLazy -> full'
tails = [CharStringLazy] -> full'
forall l. IsList l => [Item l] -> l
fromList ([CharStringLazy] -> full')
-> (CharStringLazy -> [CharStringLazy]) -> CharStringLazy -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> CharStringLazy) -> [ByteString] -> [CharStringLazy]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map ByteString -> CharStringLazy
CSL ([ByteString] -> [CharStringLazy])
-> (CharStringLazy -> [ByteString])
-> CharStringLazy
-> [CharStringLazy]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.tails (ByteString -> [ByteString])
-> (CharStringLazy -> ByteString) -> CharStringLazy -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    isPrefixOf :: Eq Char => CharStringLazy -> CharStringLazy -> Bool
isPrefixOf CharStringLazy
p CharStringLazy
f = ByteString -> ByteString -> Bool
BSL.isPrefixOf (CharStringLazy -> ByteString
unCSL CharStringLazy
p) (CharStringLazy -> ByteString
unCSL CharStringLazy
f)
    --isSuffixOf = BSL.isSuffixOf
    --isInfixOf = BSL.isInfixOf
    elem :: Eq Char => Char -> CharStringLazy -> Bool
elem Char
x = Char -> ByteString -> Bool
BSL.elem Char
x (ByteString -> Bool)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    notElem :: Eq Char => Char -> CharStringLazy -> Bool
notElem Char
x = Char -> ByteString -> Bool
BSL.notElem Char
x (ByteString -> Bool)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    find :: (Char -> Bool) -> CharStringLazy -> Maybe Char
find Char -> Bool
p = (Char -> Bool) -> ByteString -> Maybe Char
BSL.find Char -> Bool
p (ByteString -> Maybe Char)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Maybe Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    filter :: (Char -> Bool) -> CharStringLazy -> CharStringLazy
filter Char -> Bool
p = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
BSL.filter Char -> Bool
p (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    --partition = BSL.partition
    index :: CharStringLazy -> Int -> Char
index CharStringLazy
l Int
i = ByteString -> Int64 -> Char
BSL.index (CharStringLazy -> ByteString
unCSL CharStringLazy
l) (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
    elemIndex :: Eq Char => Char -> CharStringLazy -> Maybe Int
elemIndex Char
i = Maybe Int64 -> Maybe Int
mi64toi (Maybe Int64 -> Maybe Int)
-> (CharStringLazy -> Maybe Int64) -> CharStringLazy -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ByteString -> Maybe Int64
BSL.elemIndex Char
i  (ByteString -> Maybe Int64)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Maybe Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    --elemIndices x = fromList . L.map fromIntegral . BSL.elemIndices x
    findIndex :: (Char -> Bool) -> CharStringLazy -> Maybe Int
findIndex Char -> Bool
f = Maybe Int64 -> Maybe Int
mi64toi (Maybe Int64 -> Maybe Int)
-> (CharStringLazy -> Maybe Int64) -> CharStringLazy -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> Maybe Int64
BSL.findIndex Char -> Bool
f (ByteString -> Maybe Int64)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Maybe Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    --findIndices x = fromList . L.map fromIntegral . BSL.findIndices x
    --sequence = BSL.sequence
    --mapM = BSL.mapM
    --mapM_ = BSL.mapM_
    --nub = BSL.nub
    --delete = BSL.delete
    --deleteFirsts = BSL.deleteFirsts
    --union = BSL.union
    --intersect = BSL.intersect
    --sort = BSL.sort
    --insert = BSL.insert
    --toList = BSL.unpack . unCSL
    --fromList = CSL . BSL.pack
    --fromListLike = fromList . toList
    --nubBy = BSL.nubBy
    --deleteBy = BSL.deleteBy
    --deleteFirstsBy = BSL.deleteFirstsBy
    --unionBy = BSL.unionBy
    --intersectBy = BSL.intersectBy
    -- BSL.groupBy is broken. groupBy f = fromList . BSL.groupBy f
    -- the below works on ghc but generates a type error on hugs
    -- groupBy func = map fromList . L.groupBy func . toList
    --sortBy = BSL.sortBy
    --insertBy = BSL.insertBy
    genericLength :: forall a. Num a => CharStringLazy -> a
genericLength = Integer -> a
forall a. Num a => Integer -> a
fromInteger (Integer -> a)
-> (CharStringLazy -> Integer) -> CharStringLazy -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Integer)
-> (CharStringLazy -> Int64) -> CharStringLazy -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int64
BSL.length (ByteString -> Int64)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    genericTake :: forall b. Integral b => b -> CharStringLazy -> CharStringLazy
genericTake a
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> ByteString
BSL.take (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    genericDrop :: forall b. Integral b => b -> CharStringLazy -> CharStringLazy
genericDrop a
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> ByteString
BSL.drop (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> ByteString)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    genericSplitAt :: forall a.
Integral a =>
a -> CharStringLazy -> (CharStringLazy, CharStringLazy)
genericSplitAt a
i = (ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (ByteString -> CharStringLazy)
-> (ByteString, ByteString)
-> (CharStringLazy, CharStringLazy)
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** ByteString -> CharStringLazy
CSL) ((ByteString, ByteString) -> (CharStringLazy, CharStringLazy))
-> (CharStringLazy -> (ByteString, ByteString))
-> CharStringLazy
-> (CharStringLazy, CharStringLazy)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> ByteString -> (ByteString, ByteString)
BSL.splitAt (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i) (ByteString -> (ByteString, ByteString))
-> (CharStringLazy -> ByteString)
-> CharStringLazy
-> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    genericReplicate :: forall a. Integral a => a -> Char -> CharStringLazy
genericReplicate a
i = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (Char -> ByteString) -> Char -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> Char -> ByteString
BSL.replicate (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)

strict2lazy :: BS.ByteString -> CharStringLazy
strict2lazy :: ByteString -> CharStringLazy
strict2lazy ByteString
b = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy) -> ByteString -> CharStringLazy
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ByteString
BSL.fromChunks [ByteString
b]

instance ListLikeIO CharStringLazy Char where
    hGetLine :: Handle -> IO CharStringLazy
hGetLine Handle
h = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
strict2lazy (IO ByteString -> IO CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall a b. (a -> b) -> a -> b
$ Handle -> IO ByteString
BS.hGetLine Handle
h
    hGetContents :: Handle -> IO CharStringLazy
hGetContents = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
CSL (IO ByteString -> IO CharStringLazy)
-> (Handle -> IO ByteString) -> Handle -> IO CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handle -> IO ByteString
BSL.hGetContents
    hGet :: Handle -> Int -> IO CharStringLazy
hGet Handle
h Int
n = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
CSL (IO ByteString -> IO CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO ByteString
BSL.hGet Handle
h Int
n
    hGetNonBlocking :: Handle -> Int -> IO CharStringLazy
hGetNonBlocking Handle
h Int
n = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
CSL (IO ByteString -> IO CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO ByteString
BSL.hGetNonBlocking Handle
h Int
n
    hPutStr :: Handle -> CharStringLazy -> IO ()
hPutStr Handle
h = Handle -> ByteString -> IO ()
BSL.hPut Handle
h (ByteString -> IO ())
-> (CharStringLazy -> ByteString) -> CharStringLazy -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    --hPutStrLn = BSL.hPutStrLn
    getLine :: IO CharStringLazy
getLine = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
strict2lazy IO ByteString
BS.getLine
    getContents :: IO CharStringLazy
getContents = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
CSL IO ByteString
BSL.getContents
    putStr :: CharStringLazy -> IO ()
putStr = ByteString -> IO ()
BSL.putStr (ByteString -> IO ())
-> (CharStringLazy -> ByteString) -> CharStringLazy -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    putStrLn :: CharStringLazy -> IO ()
putStrLn = ByteString -> IO ()
BSL.putStrLn (ByteString -> IO ())
-> (CharStringLazy -> ByteString) -> CharStringLazy -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    interact :: (CharStringLazy -> CharStringLazy) -> IO ()
interact CharStringLazy -> CharStringLazy
f = (ByteString -> ByteString) -> IO ()
BSL.interact (CharStringLazy -> ByteString
unCSL (CharStringLazy -> ByteString)
-> (ByteString -> CharStringLazy) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> CharStringLazy
f (CharStringLazy -> CharStringLazy)
-> (ByteString -> CharStringLazy) -> ByteString -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> CharStringLazy
CSL)
    readFile :: String -> IO CharStringLazy
readFile = (ByteString -> CharStringLazy)
-> IO ByteString -> IO CharStringLazy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> CharStringLazy
CSL (IO ByteString -> IO CharStringLazy)
-> (String -> IO ByteString) -> String -> IO CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO ByteString
BSL.readFile
    writeFile :: String -> CharStringLazy -> IO ()
writeFile String
fp = String -> ByteString -> IO ()
BSL.writeFile String
fp (ByteString -> IO ())
-> (CharStringLazy -> ByteString) -> CharStringLazy -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL
    appendFile :: String -> CharStringLazy -> IO ()
appendFile String
fp = String -> ByteString -> IO ()
BSL.appendFile String
fp (ByteString -> IO ())
-> (CharStringLazy -> ByteString) -> CharStringLazy -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL

instance IsString CharStringLazy where
    fromString :: String -> CharStringLazy
fromString = ByteString -> CharStringLazy
CSL (ByteString -> CharStringLazy)
-> (String -> ByteString) -> String -> CharStringLazy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
BSL.pack

instance StringLike CharStringLazy where
    toString :: CharStringLazy -> String
toString = ByteString -> String
BSL.unpack (ByteString -> String)
-> (CharStringLazy -> ByteString) -> CharStringLazy -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CharStringLazy -> ByteString
unCSL