{-# LANGUAGE CPP
,MultiParamTypeClasses
,FlexibleInstances
,TypeFamilies
,TypeSynonymInstances #-}
{-# OPTIONS -fno-warn-orphans #-}
#if __GLASGOW_HASKELL__ > 901
{-# OPTIONS -fno-warn-incomplete-uni-patterns #-}
#endif
module Data.ListLike.Instances () 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 Prelude as P
import qualified Data.List as L
import qualified Data.Sequence as S
import Data.Sequence ((><), (|>), (<|))
import qualified Data.Foldable as F
import Data.ListLike.Base
import Data.ListLike.String
import Data.ListLike.IO
import Data.ListLike.FoldableLL
import Data.ListLike.Text ()
import Data.ListLike.UTF8 ()
import Data.ListLike.Vector ()
import Data.Int
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup(..))
#endif
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC
import qualified Data.Array.IArray as A
import Data.Array.IArray((!), (//), Ix(..))
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Lazy.Char8 as BSLC
import Data.String (IsString)
import qualified System.IO as IO
import Data.Word
import GHC.Exts (IsList(..))
instance ListLikeIO String Char where
hGetLine :: Handle -> IO String
hGetLine = Handle -> IO String
IO.hGetLine
hGetContents :: Handle -> IO String
hGetContents = Handle -> IO String
IO.hGetContents
hGet :: Handle -> Int -> IO String
hGet Handle
_ Int
c | Int
c Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = String -> IO String
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return String
forall a. Monoid a => a
mempty
hGet Handle
h Int
c = Char -> String -> String
forall full item. ListLike full item => item -> full -> full
cons (Char -> String -> String) -> IO Char -> IO (String -> String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Handle -> IO Char
IO.hGetChar Handle
h IO (String -> String) -> IO String -> IO String
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Handle -> Int -> IO String
forall full item. ListLikeIO full item => Handle -> Int -> IO full
hGet Handle
h (Int -> Int
forall a. Enum a => a -> a
pred Int
c)
hGetNonBlocking :: Handle -> Int -> IO String
hGetNonBlocking Handle
_h Int
_i = String -> IO String
forall a. HasCallStack => String -> a
error String
"Unimplemented: hGetNonBlocking in instance ListLikeIO String Char"
hPutStr :: Handle -> String -> IO ()
hPutStr = Handle -> String -> IO ()
IO.hPutStr
hPutStrLn :: Handle -> String -> IO ()
hPutStrLn = Handle -> String -> IO ()
IO.hPutStrLn
getLine :: IO String
getLine = IO String
IO.getLine
getContents :: IO String
getContents = IO String
IO.getContents
putStr :: String -> IO ()
putStr = String -> IO ()
IO.putStr
putStrLn :: String -> IO ()
putStrLn = String -> IO ()
IO.putStrLn
interact :: (String -> String) -> IO ()
interact = (String -> String) -> IO ()
IO.interact
readFile :: String -> IO String
readFile = String -> IO String
IO.readFile
writeFile :: String -> String -> IO ()
writeFile = String -> String -> IO ()
IO.writeFile
instance StringLike String where
toString :: String -> String
toString = String -> String
forall a. a -> a
id
instance InfiniteListLike [a] a where
iterate :: (a -> a) -> a -> [a]
iterate = (a -> a) -> a -> [a]
forall a. (a -> a) -> a -> [a]
L.iterate
repeat :: a -> [a]
repeat = a -> [a]
forall a. a -> [a]
L.repeat
cycle :: [a] -> [a]
cycle = [a] -> [a]
forall a. HasCallStack => [a] -> [a]
L.cycle
instance FoldableLL BS.ByteString Word8 where
foldl :: forall a. (a -> Word8 -> a) -> a -> ByteString -> a
foldl = (a -> Word8 -> a) -> a -> ByteString -> a
forall a. (a -> Word8 -> a) -> a -> ByteString -> a
BS.foldl
foldl' :: forall a. (a -> Word8 -> a) -> a -> ByteString -> a
foldl' = (a -> Word8 -> a) -> a -> ByteString -> a
forall a. (a -> Word8 -> a) -> a -> ByteString -> a
BS.foldl'
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldl1 = HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8
(Word8 -> Word8 -> Word8) -> ByteString -> Word8
BS.foldl1
foldr :: forall b. (Word8 -> b -> b) -> b -> ByteString -> b
foldr = (Word8 -> b -> b) -> b -> ByteString -> b
forall b. (Word8 -> b -> b) -> b -> ByteString -> b
BS.foldr
foldr' :: forall b. (Word8 -> b -> b) -> b -> ByteString -> b
foldr' = (Word8 -> b -> b) -> b -> ByteString -> b
forall b. (Word8 -> b -> b) -> b -> ByteString -> b
BS.foldr'
foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldr1 = HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8
(Word8 -> Word8 -> Word8) -> ByteString -> Word8
BS.foldr1
#if !MIN_VERSION_bytestring(0,10,12)
instance IsList BS.ByteString where
type Item BS.ByteString = Word8
toList = BS.unpack
fromList = BS.pack
#endif
instance ListLike BS.ByteString Word8 where
empty :: ByteString
empty = ByteString
BS.empty
singleton :: Word8 -> ByteString
singleton = Word8 -> ByteString
BS.singleton
cons :: Word8 -> ByteString -> ByteString
cons = Word8 -> ByteString -> ByteString
BS.cons
snoc :: ByteString -> Word8 -> ByteString
snoc = ByteString -> Word8 -> ByteString
BS.snoc
append :: ByteString -> ByteString -> ByteString
append = ByteString -> ByteString -> ByteString
BS.append
uncons :: ByteString -> Maybe (Word8, ByteString)
uncons = ByteString -> Maybe (Word8, ByteString)
BS.uncons
head :: ByteString -> Word8
head = HasCallStack => ByteString -> Word8
ByteString -> Word8
BS.head
last :: ByteString -> Word8
last = HasCallStack => ByteString -> Word8
ByteString -> Word8
BS.last
tail :: ByteString -> ByteString
tail = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
BS.tail
init :: ByteString -> ByteString
init = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
BS.init
null :: ByteString -> Bool
null = ByteString -> Bool
BS.null
length :: ByteString -> Int
length = ByteString -> Int
BS.length
rigidMap :: (Word8 -> Word8) -> ByteString -> ByteString
rigidMap = (Word8 -> Word8) -> ByteString -> ByteString
BS.map
reverse :: ByteString -> ByteString
reverse = ByteString -> ByteString
BS.reverse
intersperse :: Word8 -> ByteString -> ByteString
intersperse = Word8 -> ByteString -> ByteString
BS.intersperse
concat :: forall full'. ListLike full' ByteString => full' -> ByteString
concat = [ByteString] -> ByteString
BS.concat ([ByteString] -> ByteString)
-> (full' -> [ByteString]) -> full' -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. full' -> [Item full']
full' -> [ByteString]
forall l. IsList l => l -> [Item l]
toList
rigidConcatMap :: (Word8 -> ByteString) -> ByteString -> ByteString
rigidConcatMap = (Word8 -> ByteString) -> ByteString -> ByteString
BS.concatMap
any :: (Word8 -> Bool) -> ByteString -> Bool
any = (Word8 -> Bool) -> ByteString -> Bool
BS.any
all :: (Word8 -> Bool) -> ByteString -> Bool
all = (Word8 -> Bool) -> ByteString -> Bool
BS.all
maximum :: Ord Word8 => ByteString -> Word8
maximum = HasCallStack => ByteString -> Word8
ByteString -> Word8
BS.maximum
minimum :: Ord Word8 => ByteString -> Word8
minimum = HasCallStack => ByteString -> Word8
ByteString -> Word8
BS.minimum
replicate :: Int -> Word8 -> ByteString
replicate = Int -> Word8 -> ByteString
BS.replicate
take :: Int -> ByteString -> ByteString
take = Int -> ByteString -> ByteString
BS.take
drop :: Int -> ByteString -> ByteString
drop = Int -> ByteString -> ByteString
BS.drop
splitAt :: Int -> ByteString -> (ByteString, ByteString)
splitAt = Int -> ByteString -> (ByteString, ByteString)
BS.splitAt
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
takeWhile = (Word8 -> Bool) -> ByteString -> ByteString
BS.takeWhile
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
dropWhile = (Word8 -> Bool) -> ByteString -> ByteString
BS.dropWhile
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
span = (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
BS.span
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
break = (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
BS.break
group :: forall full'.
(ListLike full' ByteString, Eq Word8) =>
ByteString -> full'
group = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.group
inits :: forall full'. ListLike full' ByteString => ByteString -> full'
inits = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.inits
tails :: forall full'. ListLike full' ByteString => ByteString -> full'
tails = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BS.tails
isPrefixOf :: Eq Word8 => ByteString -> ByteString -> Bool
isPrefixOf = ByteString -> ByteString -> Bool
BS.isPrefixOf
isSuffixOf :: Eq Word8 => ByteString -> ByteString -> Bool
isSuffixOf = ByteString -> ByteString -> Bool
BS.isSuffixOf
elem :: Eq Word8 => Word8 -> ByteString -> Bool
elem = Word8 -> ByteString -> Bool
BS.elem
notElem :: Eq Word8 => Word8 -> ByteString -> Bool
notElem = Word8 -> ByteString -> Bool
BS.notElem
find :: (Word8 -> Bool) -> ByteString -> Maybe Word8
find = (Word8 -> Bool) -> ByteString -> Maybe Word8
BS.find
filter :: (Word8 -> Bool) -> ByteString -> ByteString
filter = (Word8 -> Bool) -> ByteString -> ByteString
BS.filter
index :: ByteString -> Int -> Word8
index = HasCallStack => ByteString -> Int -> Word8
ByteString -> Int -> Word8
BS.index
elemIndex :: Eq Word8 => Word8 -> ByteString -> Maybe Int
elemIndex = Word8 -> ByteString -> Maybe Int
BS.elemIndex
elemIndices :: forall result.
(Eq Word8, ListLike result Int) =>
Word8 -> ByteString -> result
elemIndices Word8
x = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (ByteString -> [Int]) -> ByteString -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString -> [Int]
BS.elemIndices Word8
x
findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int
findIndex = (Word8 -> Bool) -> ByteString -> Maybe Int
BS.findIndex
findIndices :: forall result.
ListLike result Int =>
(Word8 -> Bool) -> ByteString -> result
findIndices Word8 -> Bool
x = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (ByteString -> [Int]) -> ByteString -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Bool) -> ByteString -> [Int]
BS.findIndices Word8 -> Bool
x
sequence :: forall (m :: * -> *) fullinp.
(Applicative m, ListLike fullinp (m Word8)) =>
fullinp -> m ByteString
sequence = ([Word8] -> ByteString) -> m [Word8] -> m ByteString
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Word8] -> ByteString
[Item ByteString] -> ByteString
forall l. IsList l => [Item l] -> l
fromList (m [Word8] -> m ByteString)
-> (fullinp -> m [Word8]) -> fullinp -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [m Word8] -> m [Word8]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
P.sequenceA ([m Word8] -> m [Word8])
-> (fullinp -> [m Word8]) -> fullinp -> m [Word8]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. fullinp -> [m Word8]
fullinp -> [Item fullinp]
forall l. IsList l => l -> [Item l]
toList
mapM :: forall (m :: * -> *) full' item'.
(Applicative m, ListLike full' item') =>
(Word8 -> m item') -> ByteString -> m full'
mapM Word8 -> m item'
func = ([item'] -> full') -> m [item'] -> m full'
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [item'] -> full'
[Item full'] -> full'
forall l. IsList l => [Item l] -> l
fromList (m [item'] -> m full')
-> (ByteString -> m [item']) -> ByteString -> m full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> m item') -> [Word8] -> m [item']
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
P.traverse Word8 -> m item'
func ([Word8] -> m [item'])
-> (ByteString -> [Word8]) -> ByteString -> m [item']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Word8]
ByteString -> [Item ByteString]
forall l. IsList l => l -> [Item l]
toList
sort :: Ord Word8 => ByteString -> ByteString
sort = ByteString -> ByteString
BS.sort
groupBy :: forall full'.
(ListLike full' ByteString, Eq Word8) =>
(Word8 -> Word8 -> Bool) -> ByteString -> full'
groupBy Word8 -> Word8 -> Bool
f = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]
BS.groupBy Word8 -> Word8 -> Bool
f
genericLength :: forall a. Num a => ByteString -> a
genericLength = Integer -> a
forall a. Num a => Integer -> a
fromInteger (Integer -> a) -> (ByteString -> Integer) -> ByteString -> 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) -> (ByteString -> Int) -> ByteString -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
BS.length
genericTake :: forall a. Integral a => a -> ByteString -> ByteString
genericTake a
i = Int -> ByteString -> ByteString
BS.take (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericDrop :: forall a. Integral a => a -> ByteString -> ByteString
genericDrop a
i = Int -> ByteString -> ByteString
BS.drop (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericSplitAt :: forall a. Integral a => a -> ByteString -> (ByteString, ByteString)
genericSplitAt a
i = Int -> ByteString -> (ByteString, ByteString)
BS.splitAt (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericReplicate :: forall a. Integral a => a -> Word8 -> ByteString
genericReplicate a
i = Int -> Word8 -> ByteString
BS.replicate (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
instance ListLikeIO BS.ByteString Word8 where
hGetLine :: Handle -> IO ByteString
hGetLine = Handle -> IO ByteString
BSC.hGetLine
hGetContents :: Handle -> IO ByteString
hGetContents = Handle -> IO ByteString
BS.hGetContents
hGet :: Handle -> Int -> IO ByteString
hGet = Handle -> Int -> IO ByteString
BS.hGet
hGetNonBlocking :: Handle -> Int -> IO ByteString
hGetNonBlocking = Handle -> Int -> IO ByteString
BS.hGetNonBlocking
hPutStr :: Handle -> ByteString -> IO ()
hPutStr = Handle -> ByteString -> IO ()
BS.hPutStr
hPutStrLn :: Handle -> ByteString -> IO ()
hPutStrLn = Handle -> ByteString -> IO ()
BSC.hPutStrLn
getLine :: IO ByteString
getLine = IO ByteString
BSC.getLine
getContents :: IO ByteString
getContents = IO ByteString
BS.getContents
putStr :: ByteString -> IO ()
putStr = ByteString -> IO ()
BS.putStr
putStrLn :: ByteString -> IO ()
putStrLn = ByteString -> IO ()
BSC.putStrLn
interact :: (ByteString -> ByteString) -> IO ()
interact = (ByteString -> ByteString) -> IO ()
BS.interact
readFile :: String -> IO ByteString
readFile = String -> IO ByteString
BS.readFile
writeFile :: String -> ByteString -> IO ()
writeFile = String -> ByteString -> IO ()
BS.writeFile
appendFile :: String -> ByteString -> IO ()
appendFile = String -> ByteString -> IO ()
BS.appendFile
#if 0
instance StringLike BS.ByteString where
toString = BSU.toString
#endif
instance FoldableLL BSL.ByteString Word8 where
foldl :: forall a. (a -> Word8 -> a) -> a -> ByteString -> a
foldl = (a -> Word8 -> a) -> a -> ByteString -> a
forall a. (a -> Word8 -> a) -> a -> ByteString -> a
BSL.foldl
foldl' :: forall a. (a -> Word8 -> a) -> a -> ByteString -> a
foldl' = (a -> Word8 -> a) -> a -> ByteString -> a
forall a. (a -> Word8 -> a) -> a -> ByteString -> a
BSL.foldl'
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldl1 = HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8
(Word8 -> Word8 -> Word8) -> ByteString -> Word8
BSL.foldl1
foldr :: forall b. (Word8 -> b -> b) -> b -> ByteString -> b
foldr = (Word8 -> b -> b) -> b -> ByteString -> b
forall b. (Word8 -> b -> b) -> b -> ByteString -> b
BSL.foldr
foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldr1 = HasCallStack => (Word8 -> Word8 -> Word8) -> ByteString -> Word8
(Word8 -> Word8 -> Word8) -> ByteString -> Word8
BSL.foldr1
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)
#if !MIN_VERSION_bytestring(0,10,12)
instance IsList BSL.ByteString where
type Item BSL.ByteString = Word8
toList = BSL.unpack
fromList = BSL.pack
#endif
instance ListLike BSL.ByteString Word8 where
empty :: ByteString
empty = ByteString
BSL.empty
singleton :: Word8 -> ByteString
singleton = Word8 -> ByteString
BSL.singleton
cons :: Word8 -> ByteString -> ByteString
cons = Word8 -> ByteString -> ByteString
BSL.cons
snoc :: ByteString -> Word8 -> ByteString
snoc = ByteString -> Word8 -> ByteString
BSL.snoc
append :: ByteString -> ByteString -> ByteString
append = ByteString -> ByteString -> ByteString
BSL.append
uncons :: ByteString -> Maybe (Word8, ByteString)
uncons = ByteString -> Maybe (Word8, ByteString)
BSL.uncons
head :: ByteString -> Word8
head = HasCallStack => ByteString -> Word8
ByteString -> Word8
BSL.head
last :: ByteString -> Word8
last = HasCallStack => ByteString -> Word8
ByteString -> Word8
BSL.last
tail :: ByteString -> ByteString
tail = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
BSL.tail
init :: ByteString -> ByteString
init = HasCallStack => ByteString -> ByteString
ByteString -> ByteString
BSL.init
null :: ByteString -> Bool
null = ByteString -> Bool
BSL.null
length :: ByteString -> Int
length = Int64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> Int) -> (ByteString -> Int64) -> ByteString -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int64
BSL.length
rigidMap :: (Word8 -> Word8) -> ByteString -> ByteString
rigidMap = (Word8 -> Word8) -> ByteString -> ByteString
BSL.map
reverse :: ByteString -> ByteString
reverse = ByteString -> ByteString
BSL.reverse
concat :: forall full'. ListLike full' ByteString => full' -> ByteString
concat = [ByteString] -> ByteString
BSL.concat ([ByteString] -> ByteString)
-> (full' -> [ByteString]) -> full' -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. full' -> [Item full']
full' -> [ByteString]
forall l. IsList l => l -> [Item l]
toList
rigidConcatMap :: (Word8 -> ByteString) -> ByteString -> ByteString
rigidConcatMap = (Word8 -> ByteString) -> ByteString -> ByteString
BSL.concatMap
any :: (Word8 -> Bool) -> ByteString -> Bool
any = (Word8 -> Bool) -> ByteString -> Bool
BSL.any
all :: (Word8 -> Bool) -> ByteString -> Bool
all = (Word8 -> Bool) -> ByteString -> Bool
BSL.all
maximum :: Ord Word8 => ByteString -> Word8
maximum = HasCallStack => ByteString -> Word8
ByteString -> Word8
BSL.maximum
minimum :: Ord Word8 => ByteString -> Word8
minimum = HasCallStack => ByteString -> Word8
ByteString -> Word8
BSL.minimum
replicate :: Int -> Word8 -> ByteString
replicate Int
i = Int64 -> Word8 -> ByteString
BSL.replicate (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
take :: Int -> ByteString -> ByteString
take Int
i = Int64 -> ByteString -> ByteString
BSL.take (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
drop :: Int -> ByteString -> ByteString
drop Int
i = Int64 -> ByteString -> ByteString
BSL.drop (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
splitAt :: Int -> ByteString -> (ByteString, ByteString)
splitAt Int
i = Int64 -> ByteString -> (ByteString, ByteString)
BSL.splitAt (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
takeWhile = (Word8 -> Bool) -> ByteString -> ByteString
BSL.takeWhile
dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
dropWhile = (Word8 -> Bool) -> ByteString -> ByteString
BSL.dropWhile
span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
span = (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
BSL.span
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
break = (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
BSL.break
group :: forall full'.
(ListLike full' ByteString, Eq Word8) =>
ByteString -> full'
group = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.group
inits :: forall full'. ListLike full' ByteString => ByteString -> full'
inits = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.inits
tails :: forall full'. ListLike full' ByteString => ByteString -> full'
tails = [Item full'] -> full'
[ByteString] -> full'
forall l. IsList l => [Item l] -> l
fromList ([ByteString] -> full')
-> (ByteString -> [ByteString]) -> ByteString -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
BSL.tails
isPrefixOf :: Eq Word8 => ByteString -> ByteString -> Bool
isPrefixOf = ByteString -> ByteString -> Bool
BSL.isPrefixOf
elem :: Eq Word8 => Word8 -> ByteString -> Bool
elem = Word8 -> ByteString -> Bool
BSL.elem
notElem :: Eq Word8 => Word8 -> ByteString -> Bool
notElem = Word8 -> ByteString -> Bool
BSL.notElem
find :: (Word8 -> Bool) -> ByteString -> Maybe Word8
find = (Word8 -> Bool) -> ByteString -> Maybe Word8
BSL.find
filter :: (Word8 -> Bool) -> ByteString -> ByteString
filter = (Word8 -> Bool) -> ByteString -> ByteString
BSL.filter
index :: ByteString -> Int -> Word8
index ByteString
l Int
i = HasCallStack => ByteString -> Int64 -> Word8
ByteString -> Int64 -> Word8
BSL.index ByteString
l (Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i)
elemIndex :: Eq Word8 => Word8 -> ByteString -> Maybe Int
elemIndex Word8
i = Maybe Int64 -> Maybe Int
mi64toi (Maybe Int64 -> Maybe Int)
-> (ByteString -> Maybe Int64) -> ByteString -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word8 -> ByteString -> Maybe Int64
BSL.elemIndex Word8
i
findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int
findIndex Word8 -> Bool
f = Maybe Int64 -> Maybe Int
mi64toi (Maybe Int64 -> Maybe Int)
-> (ByteString -> Maybe Int64) -> ByteString -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> Bool) -> ByteString -> Maybe Int64
BSL.findIndex Word8 -> Bool
f
sequence :: forall (m :: * -> *) fullinp.
(Applicative m, ListLike fullinp (m Word8)) =>
fullinp -> m ByteString
sequence = ([Word8] -> ByteString) -> m [Word8] -> m ByteString
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Word8] -> ByteString
[Item ByteString] -> ByteString
forall l. IsList l => [Item l] -> l
fromList (m [Word8] -> m ByteString)
-> (fullinp -> m [Word8]) -> fullinp -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [m Word8] -> m [Word8]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
P.sequenceA ([m Word8] -> m [Word8])
-> (fullinp -> [m Word8]) -> fullinp -> m [Word8]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. fullinp -> [m Word8]
fullinp -> [Item fullinp]
forall l. IsList l => l -> [Item l]
toList
mapM :: forall (m :: * -> *) full' item'.
(Applicative m, ListLike full' item') =>
(Word8 -> m item') -> ByteString -> m full'
mapM Word8 -> m item'
func = ([item'] -> full') -> m [item'] -> m full'
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [item'] -> full'
[Item full'] -> full'
forall l. IsList l => [Item l] -> l
fromList (m [item'] -> m full')
-> (ByteString -> m [item']) -> ByteString -> m full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word8 -> m item') -> [Word8] -> m [item']
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
P.traverse Word8 -> m item'
func ([Word8] -> m [item'])
-> (ByteString -> [Word8]) -> ByteString -> m [item']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [Word8]
ByteString -> [Item ByteString]
forall l. IsList l => l -> [Item l]
toList
genericLength :: forall a. Num a => ByteString -> a
genericLength = Integer -> a
forall a. Num a => Integer -> a
fromInteger (Integer -> a) -> (ByteString -> Integer) -> ByteString -> 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)
-> (ByteString -> Int64) -> ByteString -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int64
BSL.length
genericTake :: forall a. Integral a => a -> ByteString -> ByteString
genericTake a
i = Int64 -> ByteString -> ByteString
BSL.take (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericDrop :: forall a. Integral a => a -> ByteString -> ByteString
genericDrop a
i = Int64 -> ByteString -> ByteString
BSL.drop (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericSplitAt :: forall a. Integral a => a -> ByteString -> (ByteString, ByteString)
genericSplitAt a
i = Int64 -> ByteString -> (ByteString, ByteString)
BSL.splitAt (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericReplicate :: forall a. Integral a => a -> Word8 -> ByteString
genericReplicate a
i = Int64 -> Word8 -> ByteString
BSL.replicate (a -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
strict2lazy :: BS.ByteString -> IO BSL.ByteString
strict2lazy :: ByteString -> IO ByteString
strict2lazy ByteString
b = ByteString -> IO ByteString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([ByteString] -> ByteString
BSL.fromChunks [ByteString
b])
instance ListLikeIO BSL.ByteString Word8 where
hGetLine :: Handle -> IO ByteString
hGetLine Handle
h = Handle -> IO ByteString
BSC.hGetLine Handle
h IO ByteString -> (ByteString -> IO ByteString) -> IO ByteString
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> IO ByteString
strict2lazy
hGetContents :: Handle -> IO ByteString
hGetContents = Handle -> IO ByteString
BSL.hGetContents
hGet :: Handle -> Int -> IO ByteString
hGet = Handle -> Int -> IO ByteString
BSL.hGet
hGetNonBlocking :: Handle -> Int -> IO ByteString
hGetNonBlocking = Handle -> Int -> IO ByteString
BSL.hGetNonBlocking
hPutStr :: Handle -> ByteString -> IO ()
hPutStr = Handle -> ByteString -> IO ()
BSL.hPut
getLine :: IO ByteString
getLine = IO ByteString
BSC.getLine IO ByteString -> (ByteString -> IO ByteString) -> IO ByteString
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ByteString -> IO ByteString
strict2lazy
getContents :: IO ByteString
getContents = IO ByteString
BSL.getContents
putStr :: ByteString -> IO ()
putStr = ByteString -> IO ()
BSL.putStr
putStrLn :: ByteString -> IO ()
putStrLn = ByteString -> IO ()
BSLC.putStrLn
interact :: (ByteString -> ByteString) -> IO ()
interact = (ByteString -> ByteString) -> IO ()
BSL.interact
readFile :: String -> IO ByteString
readFile = String -> IO ByteString
BSL.readFile
writeFile :: String -> ByteString -> IO ()
writeFile = String -> ByteString -> IO ()
BSL.writeFile
appendFile :: String -> ByteString -> IO ()
appendFile = String -> ByteString -> IO ()
BSL.appendFile
#if 0
instance StringLike BSL.ByteString where
toString = BSLU.toString
#endif
instance Ix i => FoldableLL (A.Array i e) e where
foldl :: forall a. (a -> e -> a) -> a -> Array i e -> a
foldl = (a -> e -> a) -> a -> Array i e -> a
forall b a. (b -> a -> b) -> b -> Array i a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl
foldl1 :: (e -> e -> e) -> Array i e -> e
foldl1 = (e -> e -> e) -> Array i e -> e
forall a. (a -> a -> a) -> Array i a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldl1
foldl' :: forall a. (a -> e -> a) -> a -> Array i e -> a
foldl' = (a -> e -> a) -> a -> Array i e -> a
forall b a. (b -> a -> b) -> b -> Array i a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl'
foldr :: forall b. (e -> b -> b) -> b -> Array i e -> b
foldr = (e -> b -> b) -> b -> Array i e -> b
forall a b. (a -> b -> b) -> b -> Array i a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr
foldr1 :: (e -> e -> e) -> Array i e -> e
foldr1 = (e -> e -> e) -> Array i e -> e
forall a. (a -> a -> a) -> Array i a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldr1
foldr' :: forall b. (e -> b -> b) -> b -> Array i e -> b
foldr' = (e -> b -> b) -> b -> Array i e -> b
forall a b. (a -> b -> b) -> b -> Array i a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr'
instance (Integral i, Ix i) => Semigroup (A.Array i e) where
Array i e
l1 <> :: Array i e -> Array i e -> Array i e
<> Array i e
l2 = (i, i) -> [(i, e)] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [(i, e)] -> a i e
A.array (i
blow, i
newbhigh) ([(i, e)] -> Array i e) -> [(i, e)] -> Array i e
forall a b. (a -> b) -> a -> b
$
Array i e -> [(i, e)]
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> [(i, e)]
A.assocs Array i e
l1 [(i, e)] -> [(i, e)] -> [(i, e)]
forall a. [a] -> [a] -> [a]
++ [i] -> [e] -> [(i, e)]
forall full item fullb itemb result.
(ListLike full item, ListLike fullb itemb,
ListLike result (item, itemb)) =>
full -> fullb -> result
zip [i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
+ i
1 .. i
newbhigh] (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l2)
where
newlen :: i
newlen = [e] -> i
forall a. Num a => [e] -> a
forall full item a. (ListLike full item, Num a) => full -> a
genericLength [e]
newelems
newelems :: [e]
newelems = Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l2
newbhigh :: i
newbhigh = i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
+ i
newlen
(i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l1
instance (Integral i, Ix i) => Monoid (A.Array i e) where
mempty :: Array i e
mempty = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
0, -i
1) []
mappend :: Array i e -> Array i e -> Array i e
mappend = Array i e -> Array i e -> Array i e
forall a. Semigroup a => a -> a -> a
(<>)
instance (Integral i, Ix i) => IsList (A.Array i e) where
type Item (A.Array i e) = e
toList :: Array i e -> [Item (Array i e)]
toList = Array i e -> [e]
Array i e -> [Item (Array i e)]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems
fromList :: [Item (Array i e)] -> Array i e
fromList [Item (Array i e)]
l = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
0, [e] -> i
forall a. Num a => [e] -> a
forall full item a. (ListLike full item, Num a) => full -> a
genericLength [e]
[Item (Array i e)]
l i -> i -> i
forall a. Num a => a -> a -> a
- i
1) [e]
[Item (Array i e)]
l
instance (Integral i, Ix i) => ListLike (A.Array i e) e where
empty :: Array i e
empty = Array i e
forall a. Monoid a => a
mempty
singleton :: e -> Array i e
singleton e
i = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
0, i
0) [e
i]
cons :: e -> Array i e -> Array i e
cons e
i Array i e
l =
((i, i) -> (i -> i) -> Array i e -> Array i e
forall (a :: * -> * -> *) e i j.
(IArray a e, Ix i, Ix j) =>
(i, i) -> (i -> j) -> a j e -> a i e
A.ixmap (i
blow i -> i -> i
forall a. Num a => a -> a -> a
- i
1, i
bhigh) i -> i
forall a. a -> a
id Array i e
l) Array i e -> [(i, e)] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> [(i, e)] -> a i e
// [(i
blow i -> i -> i
forall a. Num a => a -> a -> a
- i
1, e
i)]
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
snoc :: Array i e -> e -> Array i e
snoc Array i e
l e
i =
((i, i) -> (i -> i) -> Array i e -> Array i e
forall (a :: * -> * -> *) e i j.
(IArray a e, Ix i, Ix j) =>
(i, i) -> (i -> j) -> a j e -> a i e
A.ixmap (i
blow, i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
+ i
1) i -> i
forall a. a -> a
id Array i e
l) Array i e -> [(i, e)] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> [(i, e)] -> a i e
// [(i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
+ i
1, e
i)]
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
append :: Array i e -> Array i e -> Array i e
append = Array i e -> Array i e -> Array i e
forall a. Monoid a => a -> a -> a
mappend
head :: Array i e -> e
head Array i e
l = Array i e
l Array i e -> i -> e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> i -> e
! ((i, i) -> i
forall a b. (a, b) -> a
fst (Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l))
last :: Array i e -> e
last Array i e
l = Array i e
l Array i e -> i -> e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> i -> e
! ((i, i) -> i
forall a b. (a, b) -> b
snd (Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l))
tail :: Array i e -> Array i e
tail Array i e
l = (i, i) -> [(i, e)] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [(i, e)] -> a i e
A.array (i
blow i -> i -> i
forall a. Num a => a -> a -> a
+ i
1, i
bhigh) ([(i, e)] -> [(i, e)]
forall full item. ListLike full item => full -> full
tail (Array i e -> [(i, e)]
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> [(i, e)]
A.assocs Array i e
l))
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
init :: Array i e -> Array i e
init Array i e
l = (i, i) -> [(i, e)] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [(i, e)] -> a i e
A.array (i
blow, i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
- i
1) ([(i, e)] -> [(i, e)]
forall full item. ListLike full item => full -> full
init (Array i e -> [(i, e)]
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> [(i, e)]
A.assocs Array i e
l))
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
null :: Array i e -> Bool
null Array i e
l = Array i e -> Integer
forall a. Num a => Array i e -> a
forall full item a. (ListLike full item, Num a) => full -> a
genericLength Array i e
l Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
== (Integer
0::Integer)
length :: Array i e -> Int
length = Array i e -> Int
forall a. Num a => Array i e -> a
forall full item a. (ListLike full item, Num a) => full -> a
genericLength
rigidMap :: (e -> e) -> Array i e -> Array i e
rigidMap = (e -> e) -> Array i e -> Array i e
forall (a :: * -> * -> *) e' e i.
(IArray a e', IArray a e, Ix i) =>
(e' -> e) -> a i e' -> a i e
A.amap
reverse :: Array i e -> Array i e
reverse Array i e
l = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l) ([e] -> [e]
forall a. [a] -> [a]
L.reverse (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l))
any :: (e -> Bool) -> Array i e -> Bool
any e -> Bool
x = (e -> Bool) -> [e] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
L.any e -> Bool
x ([e] -> Bool) -> (Array i e -> [e]) -> Array i e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems
all :: (e -> Bool) -> Array i e -> Bool
all e -> Bool
x = (e -> Bool) -> [e] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
L.all e -> Bool
x ([e] -> Bool) -> (Array i e -> [e]) -> Array i e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems
maximum :: Ord e => Array i e -> e
maximum = [e] -> e
forall a. Ord a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
L.maximum ([e] -> e) -> (Array i e -> [e]) -> Array i e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems
minimum :: Ord e => Array i e -> e
minimum = [e] -> e
forall a. Ord a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
L.minimum ([e] -> e) -> (Array i e -> [e]) -> Array i e -> e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems
replicate :: Int -> e -> Array i e
replicate = Int -> e -> Array i e
forall a. Integral a => a -> e -> Array i e
forall full item a.
(ListLike full item, Integral a) =>
a -> item -> full
genericReplicate
take :: Int -> Array i e -> Array i e
take = Int -> Array i e -> Array i e
forall a. Integral a => a -> Array i e -> Array i e
forall full item a.
(ListLike full item, Integral a) =>
a -> full -> full
genericTake
drop :: Int -> Array i e -> Array i e
drop = Int -> Array i e -> Array i e
forall a. Integral a => a -> Array i e -> Array i e
forall full item a.
(ListLike full item, Integral a) =>
a -> full -> full
genericDrop
isPrefixOf :: Eq e => Array i e -> Array i e -> Bool
isPrefixOf Array i e
l1 Array i e
l2 = [e] -> [e] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
L.isPrefixOf (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l1) (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l2)
isSuffixOf :: Eq e => Array i e -> Array i e -> Bool
isSuffixOf Array i e
l1 Array i e
l2 = [e] -> [e] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
L.isSuffixOf (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l1) (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l2)
isInfixOf :: Eq e => Array i e -> Array i e -> Bool
isInfixOf Array i e
l1 Array i e
l2 = [e] -> [e] -> Bool
forall a. Eq a => [a] -> [a] -> Bool
L.isInfixOf (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l1) (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l2)
elem :: Eq e => e -> Array i e -> Bool
elem e
i Array i e
l = e -> [e] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
L.elem e
i (Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList Array i e
l)
filter :: (e -> Bool) -> Array i e -> Array i e
filter e -> Bool
f = [e] -> Array i e
[Item (Array i e)] -> Array i e
forall l. IsList l => [Item l] -> l
fromList ([e] -> Array i e) -> (Array i e -> [e]) -> Array i e -> Array i e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Bool) -> [e] -> [e]
forall a. (a -> Bool) -> [a] -> [a]
L.filter e -> Bool
f ([e] -> [e]) -> (Array i e -> [e]) -> Array i e -> [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
index :: Array i e -> Int -> e
index Array i e
l Int
i = Array i e
l Array i e -> i -> e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> i -> e
! ((Int -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
i) i -> i -> i
forall a. Num a => a -> a -> a
+ i
offset)
where offset :: i
offset = ((i, i) -> i
forall a b. (a, b) -> a
fst ((i, i) -> i) -> (i, i) -> i
forall a b. (a -> b) -> a -> b
$ Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l)
elemIndex :: Eq e => e -> Array i e -> Maybe Int
elemIndex e
i = e -> [e] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
L.elemIndex e
i ([e] -> Maybe Int) -> (Array i e -> [e]) -> Array i e -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
elemIndices :: forall result.
(Eq e, ListLike result Int) =>
e -> Array i e -> result
elemIndices e
i = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (Array i e -> [Int]) -> Array i e -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> [e] -> [Int]
forall a. Eq a => a -> [a] -> [Int]
L.elemIndices e
i ([e] -> [Int]) -> (Array i e -> [e]) -> Array i e -> [Int]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
findIndex :: (e -> Bool) -> Array i e -> Maybe Int
findIndex e -> Bool
f = (e -> Bool) -> [e] -> Maybe Int
forall a. (a -> Bool) -> [a] -> Maybe Int
L.findIndex e -> Bool
f ([e] -> Maybe Int) -> (Array i e -> [e]) -> Array i e -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
findIndices :: forall result.
ListLike result Int =>
(e -> Bool) -> Array i e -> result
findIndices e -> Bool
f = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (Array i e -> [Int]) -> Array i e -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> Bool) -> [e] -> [Int]
forall a. (a -> Bool) -> [a] -> [Int]
L.findIndices e -> Bool
f ([e] -> [Int]) -> (Array i e -> [e]) -> Array i e -> [Int]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
sequence :: forall (m :: * -> *) fullinp.
(Applicative m, ListLike fullinp (m e)) =>
fullinp -> m (Array i e)
sequence = ([e] -> Array i e) -> m [e] -> m (Array i e)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [e] -> Array i e
[Item (Array i e)] -> Array i e
forall l. IsList l => [Item l] -> l
fromList (m [e] -> m (Array i e))
-> (fullinp -> m [e]) -> fullinp -> m (Array i e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [m e] -> m [e]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
P.sequenceA ([m e] -> m [e]) -> (fullinp -> [m e]) -> fullinp -> m [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. fullinp -> [m e]
fullinp -> [Item fullinp]
forall l. IsList l => l -> [Item l]
toList
mapM :: forall (m :: * -> *) full' item'.
(Applicative m, ListLike full' item') =>
(e -> m item') -> Array i e -> m full'
mapM e -> m item'
func = ([item'] -> full') -> m [item'] -> m full'
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [item'] -> full'
[Item full'] -> full'
forall l. IsList l => [Item l] -> l
fromList (m [item'] -> m full')
-> (Array i e -> m [item']) -> Array i e -> m full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> m item') -> [e] -> m [item']
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
P.traverse e -> m item'
func ([e] -> m [item']) -> (Array i e -> [e]) -> Array i e -> m [item']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
nub :: Eq e => Array i e -> Array i e
nub = [e] -> Array i e
[Item (Array i e)] -> Array i e
forall l. IsList l => [Item l] -> l
fromList ([e] -> Array i e) -> (Array i e -> [e]) -> Array i e -> Array i e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [e] -> [e]
forall a. Eq a => [a] -> [a]
L.nub ([e] -> [e]) -> (Array i e -> [e]) -> Array i e -> [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
sort :: Ord e => Array i e -> Array i e
sort Array i e
l = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l) ([e] -> [e]
forall a. Ord a => [a] -> [a]
L.sort (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l))
nubBy :: (e -> e -> Bool) -> Array i e -> Array i e
nubBy e -> e -> Bool
f = [e] -> Array i e
[Item (Array i e)] -> Array i e
forall l. IsList l => [Item l] -> l
fromList ([e] -> Array i e) -> (Array i e -> [e]) -> Array i e -> Array i e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (e -> e -> Bool) -> [e] -> [e]
forall a. (a -> a -> Bool) -> [a] -> [a]
L.nubBy e -> e -> Bool
f ([e] -> [e]) -> (Array i e -> [e]) -> Array i e -> [e]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i e -> [e]
Array i e -> [Item (Array i e)]
forall l. IsList l => l -> [Item l]
toList
sortBy :: (e -> e -> Ordering) -> Array i e -> Array i e
sortBy e -> e -> Ordering
f Array i e
l = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l) ((e -> e -> Ordering) -> [e] -> [e]
forall a. (a -> a -> Ordering) -> [a] -> [a]
L.sortBy e -> e -> Ordering
f (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l))
genericLength :: forall a. Num a => Array i e -> a
genericLength Array i e
l = i -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i
bhigh i -> i -> i
forall a. Num a => a -> a -> a
- i
blow i -> i -> i
forall a. Num a => a -> a -> a
+ i
1)
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
genericTake :: forall a. Integral a => a -> Array i e -> Array i e
genericTake a
count Array i e
l
| a
count a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> Array i e -> a
forall a. Num a => Array i e -> a
forall full item a. (ListLike full item, Num a) => full -> a
genericLength Array i e
l = Array i e
l
| a
count a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
0 = Array i e
forall full item. ListLike full item => full
empty
| Bool
otherwise = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
blow, i
blow i -> i -> i
forall a. Num a => a -> a -> a
+ (a -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
count) i -> i -> i
forall a. Num a => a -> a -> a
- i
1)
(a -> [e] -> [e]
forall i a. Integral i => i -> [a] -> [a]
L.genericTake a
count (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l))
where (i
blow, i
_) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
genericDrop :: forall a. Integral a => a -> Array i e -> Array i e
genericDrop a
count Array i e
l = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
blow i -> i -> i
forall a. Num a => a -> a -> a
+ (a -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
count), i
bhigh)
(a -> [e] -> [e]
forall i a. Integral i => i -> [a] -> [a]
L.genericDrop a
count (Array i e -> [e]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
A.elems Array i e
l))
where (i
blow, i
bhigh) = Array i e -> (i, i)
forall i. Ix i => Array i e -> (i, i)
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
a i e -> (i, i)
A.bounds Array i e
l
genericReplicate :: forall a. Integral a => a -> e -> Array i e
genericReplicate a
count e
i = (i, i) -> [e] -> Array i e
forall (a :: * -> * -> *) e i.
(IArray a e, Ix i) =>
(i, i) -> [e] -> a i e
A.listArray (i
0, (a -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
count) i -> i -> i
forall a. Num a => a -> a -> a
- i
1)
(a -> e -> [e]
forall i a. Integral i => i -> a -> [a]
L.genericReplicate a
count e
i)
instance (Integral i, Ix i) => IsString (A.Array i Char) where
fromString :: String -> Array i Char
fromString = String -> Array i Char
[Item (Array i Char)] -> Array i Char
forall l. IsList l => [Item l] -> l
fromList
instance (Integral i, Ix i) => StringLike (A.Array i Char) where
toString :: Array i Char -> String
toString = Array i Char -> String
Array i Char -> [Item (Array i Char)]
forall l. IsList l => l -> [Item l]
toList
instance (Integral i, Ix i) => ListLikeIO (A.Array i Char) Char where
hGetLine :: Handle -> IO (Array i Char)
hGetLine Handle
h = Handle -> IO String
IO.hGetLine Handle
h IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
[Item (Array i Char)] -> Array i Char
forall l. IsList l => [Item l] -> l
fromList)
hGetContents :: Handle -> IO (Array i Char)
hGetContents Handle
h = Handle -> IO String
IO.hGetContents Handle
h IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
[Item (Array i Char)] -> Array i Char
forall l. IsList l => [Item l] -> l
fromList)
hGet :: Handle -> Int -> IO (Array i Char)
hGet Handle
h Int
i = ((Handle -> Int -> IO String
forall full item. ListLikeIO full item => Handle -> Int -> IO full
hGet Handle
h Int
i)::IO String) IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
[Item (Array i Char)] -> Array i Char
forall l. IsList l => [Item l] -> l
fromList)
hGetNonBlocking :: Handle -> Int -> IO (Array i Char)
hGetNonBlocking Handle
h Int
i = ((Handle -> Int -> IO String
forall full item. ListLikeIO full item => Handle -> Int -> IO full
hGetNonBlocking Handle
h Int
i):: IO String) IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
[Item (Array i Char)] -> Array i Char
forall l. IsList l => [Item l] -> l
fromList)
hPutStr :: Handle -> Array i Char -> IO ()
hPutStr Handle
h = Handle -> String -> IO ()
forall full item. ListLikeIO full item => Handle -> full -> IO ()
hPutStr Handle
h (String -> IO ())
-> (Array i Char -> String) -> Array i Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i Char -> String
forall s. StringLike s => s -> String
toString
hPutStrLn :: Handle -> Array i Char -> IO ()
hPutStrLn Handle
h = Handle -> String -> IO ()
forall full item. ListLikeIO full item => Handle -> full -> IO ()
hPutStrLn Handle
h (String -> IO ())
-> (Array i Char -> String) -> Array i Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i Char -> String
forall s. StringLike s => s -> String
toString
getLine :: IO (Array i Char)
getLine = IO String
IO.getLine IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
forall a. IsString a => String -> a
fromString)
getContents :: IO (Array i Char)
getContents = IO String
IO.getContents IO String -> (String -> IO (Array i Char)) -> IO (Array i Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Array i Char -> IO (Array i Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Array i Char -> IO (Array i Char))
-> (String -> Array i Char) -> String -> IO (Array i Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Array i Char
forall a. IsString a => String -> a
fromString)
putStr :: Array i Char -> IO ()
putStr = String -> IO ()
IO.putStr (String -> IO ())
-> (Array i Char -> String) -> Array i Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i Char -> String
forall s. StringLike s => s -> String
toString
putStrLn :: Array i Char -> IO ()
putStrLn = String -> IO ()
IO.putStrLn (String -> IO ())
-> (Array i Char -> String) -> Array i Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array i Char -> String
forall s. StringLike s => s -> String
toString
instance ListLikeIO (S.Seq Char) Char where
hGetLine :: Handle -> IO (Seq Char)
hGetLine Handle
h = Handle -> IO String
IO.hGetLine Handle
h IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
[Item (Seq Char)] -> Seq Char
forall l. IsList l => [Item l] -> l
fromList)
hGetContents :: Handle -> IO (Seq Char)
hGetContents Handle
h = Handle -> IO String
IO.hGetContents Handle
h IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
[Item (Seq Char)] -> Seq Char
forall l. IsList l => [Item l] -> l
fromList)
hGet :: Handle -> Int -> IO (Seq Char)
hGet Handle
h Int
i = ((Handle -> Int -> IO String
forall full item. ListLikeIO full item => Handle -> Int -> IO full
hGet Handle
h Int
i)::IO String) IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
[Item (Seq Char)] -> Seq Char
forall l. IsList l => [Item l] -> l
fromList)
hGetNonBlocking :: Handle -> Int -> IO (Seq Char)
hGetNonBlocking Handle
h Int
i = ((Handle -> Int -> IO String
forall full item. ListLikeIO full item => Handle -> Int -> IO full
hGetNonBlocking Handle
h Int
i):: IO String) IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
[Item (Seq Char)] -> Seq Char
forall l. IsList l => [Item l] -> l
fromList)
hPutStr :: Handle -> Seq Char -> IO ()
hPutStr Handle
h = Handle -> String -> IO ()
forall full item. ListLikeIO full item => Handle -> full -> IO ()
hPutStr Handle
h (String -> IO ()) -> (Seq Char -> String) -> Seq Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq Char -> String
forall s. StringLike s => s -> String
toString
hPutStrLn :: Handle -> Seq Char -> IO ()
hPutStrLn Handle
h = Handle -> String -> IO ()
forall full item. ListLikeIO full item => Handle -> full -> IO ()
hPutStrLn Handle
h (String -> IO ()) -> (Seq Char -> String) -> Seq Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq Char -> String
forall s. StringLike s => s -> String
toString
getLine :: IO (Seq Char)
getLine = IO String
IO.getLine IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
forall a. IsString a => String -> a
fromString)
getContents :: IO (Seq Char)
getContents = IO String
IO.getContents IO String -> (String -> IO (Seq Char)) -> IO (Seq Char)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Seq Char -> IO (Seq Char)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Seq Char -> IO (Seq Char))
-> (String -> Seq Char) -> String -> IO (Seq Char)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Seq Char
forall a. IsString a => String -> a
fromString)
putStr :: Seq Char -> IO ()
putStr = String -> IO ()
IO.putStr (String -> IO ()) -> (Seq Char -> String) -> Seq Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq Char -> String
forall s. StringLike s => s -> String
toString
putStrLn :: Seq Char -> IO ()
putStrLn = String -> IO ()
IO.putStrLn (String -> IO ()) -> (Seq Char -> String) -> Seq Char -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq Char -> String
forall s. StringLike s => s -> String
toString
#if !MIN_VERSION_containers(0,5,7)
instance IsString (S.Seq Char) where
fromString = S.fromList
#endif
instance StringLike (S.Seq Char) where
toString :: Seq Char -> String
toString = Seq Char -> String
Seq Char -> [Item (Seq Char)]
forall l. IsList l => l -> [Item l]
toList
instance FoldableLL (S.Seq a) a where
foldl :: forall a. (a -> a -> a) -> a -> Seq a -> a
foldl = (a -> a -> a) -> a -> Seq a -> a
forall b a. (b -> a -> b) -> b -> Seq a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl
foldl' :: forall a. (a -> a -> a) -> a -> Seq a -> a
foldl' = (a -> a -> a) -> a -> Seq a -> a
forall b a. (b -> a -> b) -> b -> Seq a -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl'
foldl1 :: (a -> a -> a) -> Seq a -> a
foldl1 = (a -> a -> a) -> Seq a -> a
forall a. (a -> a -> a) -> Seq a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldl1
foldr :: forall b. (a -> b -> b) -> b -> Seq a -> b
foldr = (a -> b -> b) -> b -> Seq a -> b
forall a b. (a -> b -> b) -> b -> Seq a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr
foldr' :: forall b. (a -> b -> b) -> b -> Seq a -> b
foldr' = (a -> b -> b) -> b -> Seq a -> b
forall a b. (a -> b -> b) -> b -> Seq a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr'
foldr1 :: (a -> a -> a) -> Seq a -> a
foldr1 = (a -> a -> a) -> Seq a -> a
forall a. (a -> a -> a) -> Seq a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldr1
instance ListLike (S.Seq a) a where
empty :: Seq a
empty = Seq a
forall a. Seq a
S.empty
singleton :: a -> Seq a
singleton = a -> Seq a
forall a. a -> Seq a
S.singleton
cons :: a -> Seq a -> Seq a
cons = a -> Seq a -> Seq a
forall a. a -> Seq a -> Seq a
(<|)
snoc :: Seq a -> a -> Seq a
snoc = Seq a -> a -> Seq a
forall a. Seq a -> a -> Seq a
(|>)
append :: Seq a -> Seq a -> Seq a
append = Seq a -> Seq a -> Seq a
forall a. Seq a -> Seq a -> Seq a
(><)
head :: Seq a -> a
head Seq a
s = let (a
a S.:< Seq a
_) = Seq a -> ViewL a
forall a. Seq a -> ViewL a
S.viewl Seq a
s in a
a
last :: Seq a -> a
last Seq a
s = let (Seq a
_ S.:> a
a) = Seq a -> ViewR a
forall a. Seq a -> ViewR a
S.viewr Seq a
s in a
a
tail :: Seq a -> Seq a
tail Seq a
s = Seq (Seq a) -> Int -> Seq a
forall a. Seq a -> Int -> a
S.index (Seq a -> Seq (Seq a)
forall a. Seq a -> Seq (Seq a)
S.tails Seq a
s) Int
1
init :: Seq a -> Seq a
init Seq a
s = Seq (Seq a) -> Int -> Seq a
forall a. Seq a -> Int -> a
S.index (Seq a -> Seq (Seq a)
forall a. Seq a -> Seq (Seq a)
S.inits Seq a
s) (Seq a -> Int
forall a. Seq a -> Int
S.length Seq a
s Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
null :: Seq a -> Bool
null = Seq a -> Bool
forall a. Seq a -> Bool
S.null
length :: Seq a -> Int
length = Seq a -> Int
forall a. Seq a -> Int
S.length
map :: forall full' item'.
ListLike full' item' =>
(a -> item') -> Seq a -> full'
map a -> item'
f = [item'] -> full'
[Item full'] -> full'
forall l. IsList l => [Item l] -> l
fromList ([item'] -> full') -> (Seq a -> [item']) -> Seq a -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq item' -> [item']
Seq item' -> [Item (Seq item')]
forall l. IsList l => l -> [Item l]
toList (Seq item' -> [item']) -> (Seq a -> Seq item') -> Seq a -> [item']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> item') -> Seq a -> Seq item'
forall a b. (a -> b) -> Seq a -> Seq b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> item'
f
reverse :: Seq a -> Seq a
reverse = Seq a -> Seq a
forall a. Seq a -> Seq a
S.reverse
any :: (a -> Bool) -> Seq a -> Bool
any = (a -> Bool) -> Seq a -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.any
all :: (a -> Bool) -> Seq a -> Bool
all = (a -> Bool) -> Seq a -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.all
maximum :: Ord a => Seq a -> a
maximum = Seq a -> a
forall a. Ord a => Seq a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum
minimum :: Ord a => Seq a -> a
minimum = Seq a -> a
forall a. Ord a => Seq a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.minimum
replicate :: Int -> a -> Seq a
replicate Int
n = Int -> a -> Seq a
forall a. Int -> a -> Seq a
S.replicate (if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0 then Int
n else Int
0)
take :: Int -> Seq a -> Seq a
take = Int -> Seq a -> Seq a
forall a. Int -> Seq a -> Seq a
S.take
drop :: Int -> Seq a -> Seq a
drop = Int -> Seq a -> Seq a
forall a. Int -> Seq a -> Seq a
S.drop
splitAt :: Int -> Seq a -> (Seq a, Seq a)
splitAt = Int -> Seq a -> (Seq a, Seq a)
forall a. Int -> Seq a -> (Seq a, Seq a)
S.splitAt
span :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
span = (a -> Bool) -> Seq a -> (Seq a, Seq a)
forall a. (a -> Bool) -> Seq a -> (Seq a, Seq a)
S.spanl
inits :: forall full'. ListLike full' (Seq a) => Seq a -> full'
inits = [Item full'] -> full'
[Seq a] -> full'
forall l. IsList l => [Item l] -> l
fromList ([Seq a] -> full') -> (Seq a -> [Seq a]) -> Seq a -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq (Seq a) -> [Item (Seq (Seq a))]
Seq (Seq a) -> [Seq a]
forall l. IsList l => l -> [Item l]
toList (Seq (Seq a) -> [Seq a])
-> (Seq a -> Seq (Seq a)) -> Seq a -> [Seq a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> Seq (Seq a)
forall a. Seq a -> Seq (Seq a)
S.inits
tails :: forall full'. ListLike full' (Seq a) => Seq a -> full'
tails = [Item full'] -> full'
[Seq a] -> full'
forall l. IsList l => [Item l] -> l
fromList ([Seq a] -> full') -> (Seq a -> [Seq a]) -> Seq a -> full'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq (Seq a) -> [Item (Seq (Seq a))]
Seq (Seq a) -> [Seq a]
forall l. IsList l => l -> [Item l]
toList (Seq (Seq a) -> [Seq a])
-> (Seq a -> Seq (Seq a)) -> Seq a -> [Seq a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> Seq (Seq a)
forall a. Seq a -> Seq (Seq a)
S.tails
filter :: (a -> Bool) -> Seq a -> Seq a
filter = (a -> Bool) -> Seq a -> Seq a
forall a. (a -> Bool) -> Seq a -> Seq a
S.filter
partition :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
partition = (a -> Bool) -> Seq a -> (Seq a, Seq a)
forall a. (a -> Bool) -> Seq a -> (Seq a, Seq a)
S.partition
index :: Seq a -> Int -> a
index = Seq a -> Int -> a
forall a. Seq a -> Int -> a
S.index
elemIndex :: Eq a => a -> Seq a -> Maybe Int
elemIndex = a -> Seq a -> Maybe Int
forall a. Eq a => a -> Seq a -> Maybe Int
S.elemIndexL
elemIndices :: forall result. (Eq a, ListLike result Int) => a -> Seq a -> result
elemIndices a
p = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (Seq a -> [Int]) -> Seq a -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Seq a -> [Int]
forall a. Eq a => a -> Seq a -> [Int]
S.elemIndicesL a
p
findIndex :: (a -> Bool) -> Seq a -> Maybe Int
findIndex = (a -> Bool) -> Seq a -> Maybe Int
forall a. (a -> Bool) -> Seq a -> Maybe Int
S.findIndexL
findIndices :: forall result.
ListLike result Int =>
(a -> Bool) -> Seq a -> result
findIndices a -> Bool
p = [Int] -> result
[Item result] -> result
forall l. IsList l => [Item l] -> l
fromList ([Int] -> result) -> (Seq a -> [Int]) -> Seq a -> result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Seq a -> [Int]
forall a. (a -> Bool) -> Seq a -> [Int]
S.findIndicesL a -> Bool
p
sort :: Ord a => Seq a -> Seq a
sort = Seq a -> Seq a
forall a. Ord a => Seq a -> Seq a
S.sort
sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
sortBy = (a -> a -> Ordering) -> Seq a -> Seq a
forall a. (a -> a -> Ordering) -> Seq a -> Seq a
S.sortBy
genericLength :: forall a. Num a => Seq a -> a
genericLength = Integer -> a
forall a. Num a => Integer -> a
fromInteger (Integer -> a) -> (Seq a -> Integer) -> Seq a -> 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) -> (Seq a -> Int) -> Seq a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> Int
forall a. Seq a -> Int
S.length
genericTake :: forall a. Integral a => a -> Seq a -> Seq a
genericTake a
i = Int -> Seq a -> Seq a
forall a. Int -> Seq a -> Seq a
S.take (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericDrop :: forall a. Integral a => a -> Seq a -> Seq a
genericDrop a
i = Int -> Seq a -> Seq a
forall a. Int -> Seq a -> Seq a
S.drop (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericSplitAt :: forall a. Integral a => a -> Seq a -> (Seq a, Seq a)
genericSplitAt a
i = Int -> Seq a -> (Seq a, Seq a)
forall a. Int -> Seq a -> (Seq a, Seq a)
S.splitAt (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)
genericReplicate :: forall a. Integral a => a -> a -> Seq a
genericReplicate a
i = Int -> a -> Seq a
forall a. Int -> a -> Seq a
S.replicate (a -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral a
i)