{-# LANGUAGE Trustworthy #-}
module Data.Text.Short
(
ShortText
, empty
, singleton
, pack
, append
, concat
, cons
, snoc
, replicate
, unpack
, uncons
, unsnoc
, null
, length
, isAscii
, all
, any
, find
, isPrefixOf
, isSuffixOf
, (!?)
, indexMaybe
, indexEndMaybe
, findIndex
, take
, takeEnd
, drop
, dropEnd
, takeWhile
, takeWhileEnd
, dropWhile
, dropWhileEnd
, dropAround
, splitAt
, splitAtEnd
, span
, break
, spanEnd
, breakEnd
, split
, stripPrefix
, stripSuffix
, intersperse
, intercalate
, reverse
, filter
, foldl
, foldl'
, foldr
, fromString
, toString
, fromText
, toText
, fromShortByteString
, toShortByteString
, fromByteString
, toByteString
, toBuilder
) where
import Data.Semigroup
import Data.Text.Short.Internal
import Prelude ()
break :: (Char -> Bool) -> ShortText -> (ShortText,ShortText)
break :: (Char -> Bool) -> ShortText -> (ShortText, ShortText)
break Char -> Bool
p ShortText
st = (Char -> Bool) -> ShortText -> (ShortText, ShortText)
span (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
p) ShortText
st
breakEnd :: (Char -> Bool) -> ShortText -> (ShortText,ShortText)
breakEnd :: (Char -> Bool) -> ShortText -> (ShortText, ShortText)
breakEnd Char -> Bool
p ShortText
st = (Char -> Bool) -> ShortText -> (ShortText, ShortText)
spanEnd (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
p) ShortText
st
(!?) :: ShortText -> Int -> Maybe Char
!? :: ShortText -> Int -> Maybe Char
(!?) = ShortText -> Int -> Maybe Char
indexMaybe
any :: (Char -> Bool) -> ShortText -> Bool
any :: (Char -> Bool) -> ShortText -> Bool
any Char -> Bool
p ShortText
st = case (Char -> Bool) -> ShortText -> Maybe Char
find Char -> Bool
p ShortText
st of
Maybe Char
Nothing -> Bool
False
Just Char
_ -> Bool
True
append :: ShortText -> ShortText -> ShortText
append :: ShortText -> ShortText -> ShortText
append = ShortText -> ShortText -> ShortText
forall a. Semigroup a => a -> a -> a
(<>)
concat :: [ShortText] -> ShortText
concat :: [ShortText] -> ShortText
concat = [ShortText] -> ShortText
forall a. Monoid a => [a] -> a
mconcat
empty :: ShortText
empty :: ShortText
empty = ShortText
forall a. Monoid a => a
mempty
pack :: [Char] -> ShortText
pack :: [Char] -> ShortText
pack = [Char] -> ShortText
fromString
unpack :: ShortText -> [Char]
unpack :: ShortText -> [Char]
unpack = ShortText -> [Char]
toString
take :: Int -> ShortText -> ShortText
take :: Int -> ShortText -> ShortText
take Int
n = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> a
fst ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShortText -> (ShortText, ShortText)
splitAt Int
n
takeEnd :: Int -> ShortText -> ShortText
takeEnd :: Int -> ShortText -> ShortText
takeEnd Int
n = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> b
snd ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShortText -> (ShortText, ShortText)
splitAtEnd Int
n
drop :: Int -> ShortText -> ShortText
drop :: Int -> ShortText -> ShortText
drop Int
n = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> b
snd ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShortText -> (ShortText, ShortText)
splitAt Int
n
dropEnd :: Int -> ShortText -> ShortText
dropEnd :: Int -> ShortText -> ShortText
dropEnd Int
n = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> a
fst ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShortText -> (ShortText, ShortText)
splitAtEnd Int
n
takeWhile :: (Char -> Bool) -> ShortText -> ShortText
takeWhile :: (Char -> Bool) -> ShortText -> ShortText
takeWhile Char -> Bool
p = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> a
fst ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShortText -> (ShortText, ShortText)
span Char -> Bool
p
takeWhileEnd :: (Char -> Bool) -> ShortText -> ShortText
takeWhileEnd :: (Char -> Bool) -> ShortText -> ShortText
takeWhileEnd Char -> Bool
p = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> b
snd ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShortText -> (ShortText, ShortText)
spanEnd Char -> Bool
p
dropWhile :: (Char -> Bool) -> ShortText -> ShortText
dropWhile :: (Char -> Bool) -> ShortText -> ShortText
dropWhile Char -> Bool
p = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> b
snd ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShortText -> (ShortText, ShortText)
span Char -> Bool
p
dropWhileEnd :: (Char -> Bool) -> ShortText -> ShortText
dropWhileEnd :: (Char -> Bool) -> ShortText -> ShortText
dropWhileEnd Char -> Bool
p = (ShortText, ShortText) -> ShortText
forall a b. (a, b) -> a
fst ((ShortText, ShortText) -> ShortText)
-> (ShortText -> (ShortText, ShortText)) -> ShortText -> ShortText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShortText -> (ShortText, ShortText)
spanEnd Char -> Bool
p