-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Generic support for list-like structures
--
-- Generic support for list-like structures in Haskell.
--
-- The ListLike module provides a common interface to the various Haskell
-- types that are list-like. Predefined interfaces include standard
-- Haskell lists, Arrays, ByteStrings, and lazy ByteStrings. Custom types
-- can easily be made ListLike instances as well.
--
-- ListLike also provides for String-like types, such as String and
-- ByteString, for types that support input and output, and for types
-- that can handle infinite lists.
@package ListLike
@version 2.0.1
-- | Generic tools for data structures that can be folded.
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.FoldableLL
-- | This is the primary class for structures that are to be considered
-- foldable. A minimum complete definition provides foldl and
-- foldr.
--
-- Instances of FoldableLL can be folded, and can be many and
-- varied.
--
-- These functions are used heavily in Data.ListLike.
class FoldableLL full item | full -> item
foldl :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
foldl' :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
foldl1 :: FoldableLL full item => (item -> item -> item) -> full -> item
foldr :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
foldr' :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
foldr1 :: FoldableLL full item => (item -> item -> item) -> full -> item
-- | Combine the elements of a structure using a monoid. fold =
-- foldMap id
fold :: (FoldableLL full item, Monoid item) => full -> item
-- | Map each element to a monoid, then combine the results
foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m
instance FoldableLL [a] a
-- | Generic operations over list-like structures
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.Base
-- | The class implementing list-like functions.
--
-- It is worth noting that types such as Data.Map.Map can be
-- instances of ListLike. Due to their specific ways of operating,
-- they may not behave in the expected way in some cases. For instance,
-- cons may not increase the size of a map if the key you have
-- given is already in the map; it will just replace the value already
-- there.
--
-- Implementators must define at least:
--
--
-- - singleton
-- - head
-- - tail
-- - null or genericLength
--
class (FoldableLL full item, Monoid full) => ListLike full item | full -> item
empty :: ListLike full item => full
singleton :: ListLike full item => item -> full
cons :: ListLike full item => item -> full -> full
snoc :: ListLike full item => full -> item -> full
append :: ListLike full item => full -> full -> full
head :: ListLike full item => full -> item
last :: ListLike full item => full -> item
tail :: ListLike full item => full -> full
init :: ListLike full item => full -> full
null :: ListLike full item => full -> Bool
length :: ListLike full item => full -> Int
map :: (ListLike full item, ListLike full' item') => (item -> item') -> full -> full'
rigidMap :: ListLike full item => (item -> item) -> full -> full
reverse :: ListLike full item => full -> full
intersperse :: ListLike full item => item -> full -> full
concat :: (ListLike full item, ListLike full' full, Monoid full) => full' -> full
concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full'
rigidConcatMap :: ListLike full item => (item -> full) -> full -> full
any :: ListLike full item => (item -> Bool) -> full -> Bool
all :: ListLike full item => (item -> Bool) -> full -> Bool
maximum :: (ListLike full item, Ord item) => full -> item
minimum :: (ListLike full item, Ord item) => full -> item
replicate :: ListLike full item => Int -> item -> full
take :: ListLike full item => Int -> full -> full
drop :: ListLike full item => Int -> full -> full
splitAt :: ListLike full item => Int -> full -> (full, full)
takeWhile :: ListLike full item => (item -> Bool) -> full -> full
dropWhile :: ListLike full item => (item -> Bool) -> full -> full
span :: ListLike full item => (item -> Bool) -> full -> (full, full)
break :: ListLike full item => (item -> Bool) -> full -> (full, full)
group :: (ListLike full item, ListLike full' full, Eq item) => full -> full'
inits :: (ListLike full item, ListLike full' full) => full -> full'
tails :: (ListLike full item, ListLike full' full) => full -> full'
isPrefixOf :: (ListLike full item, Eq item) => full -> full -> Bool
isSuffixOf :: (ListLike full item, Eq item) => full -> full -> Bool
isInfixOf :: (ListLike full item, Eq item) => full -> full -> Bool
elem :: (ListLike full item, Eq item) => item -> full -> Bool
notElem :: (ListLike full item, Eq item) => item -> full -> Bool
find :: ListLike full item => (item -> Bool) -> full -> Maybe item
filter :: ListLike full item => (item -> Bool) -> full -> full
partition :: ListLike full item => (item -> Bool) -> full -> (full, full)
index :: ListLike full item => full -> Int -> item
elemIndex :: (ListLike full item, Eq item) => item -> full -> Maybe Int
elemIndices :: (ListLike full item, Eq item, ListLike result Int) => item -> full -> result
findIndex :: ListLike full item => (item -> Bool) -> full -> Maybe Int
findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result
sequence :: (ListLike full item, Monad m, ListLike fullinp (m item)) => fullinp -> m full
mapM :: (ListLike full item, Monad m, ListLike full' item') => (item -> m item') -> full -> m full'
rigidMapM :: (ListLike full item, Monad m) => (item -> m item) -> full -> m full
mapM_ :: (ListLike full item, Monad m) => (item -> m b) -> full -> m ()
nub :: (ListLike full item, Eq item) => full -> full
delete :: (ListLike full item, Eq item) => item -> full -> full
deleteFirsts :: (ListLike full item, Eq item) => full -> full -> full
union :: (ListLike full item, Eq item) => full -> full -> full
intersect :: (ListLike full item, Eq item) => full -> full -> full
sort :: (ListLike full item, Ord item) => full -> full
insert :: (ListLike full item, Ord item) => item -> full -> full
toList :: ListLike full item => full -> [item]
fromList :: ListLike full item => [item] -> full
fromListLike :: (ListLike full item, ListLike full' item) => full -> full'
nubBy :: ListLike full item => (item -> item -> Bool) -> full -> full
deleteBy :: ListLike full item => (item -> item -> Bool) -> item -> full -> full
deleteFirstsBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
unionBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
intersectBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
groupBy :: (ListLike full item, ListLike full' full, Eq item) => (item -> item -> Bool) -> full -> full'
sortBy :: (ListLike full item, Ord item) => (item -> item -> Ordering) -> full -> full
insertBy :: (ListLike full item, Ord item) => (item -> item -> Ordering) -> item -> full -> full
genericLength :: (ListLike full item, Num a) => full -> a
genericTake :: (ListLike full item, Integral a) => a -> full -> full
genericDrop :: (ListLike full item, Integral a) => a -> full -> full
genericSplitAt :: (ListLike full item, Integral a) => a -> full -> (full, full)
genericReplicate :: (ListLike full item, Integral a) => a -> item -> full
-- | An extension to ListLike for those data types that are capable
-- of dealing with infinite lists. Some ListLike functions are
-- capable of working with finite or infinite lists. The functions here
-- require infinite list capability in order to work at all.
class ListLike full item => InfiniteListLike full item | full -> item
iterate :: InfiniteListLike full item => (item -> item) -> item -> full
repeat :: InfiniteListLike full item => item -> full
cycle :: InfiniteListLike full item => full -> full
-- | Takes two lists and returns a list of corresponding pairs.
zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result
-- | Takes two lists and combines them with a custom combining function
zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result
-- | Evaluate each action, ignoring the results
sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()
instance ListLike [a] a
-- | String-like functions
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.String
-- | An extension to ListLike for those data types that are similar
-- to a String. Minimal complete definition is toString and
-- fromString.
class StringLike s
toString :: StringLike s => s -> String
fromString :: StringLike s => String -> s
lines :: (StringLike s, ListLike full s) => s -> full
words :: (StringLike s, ListLike full s) => s -> full
unlines :: (StringLike s, ListLike full s) => full -> s
unwords :: (StringLike s, ListLike full s) => full -> s
-- | Utilities for Data.ListLike.ListLike and friends. More
-- functions similar to Data.List but not part of the main
-- typeclass.
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.Utils
-- | Returns True if all elements are True
and :: ListLike full Bool => full -> Bool
-- | Returns True if any element is True
or :: ListLike full Bool => full -> Bool
-- | The sum of the list
sum :: (Num a, ListLike full a) => full -> a
-- | The product of the list
product :: (Num a, ListLike full a) => full -> a
-- | Takes two lists and returns a list of corresponding pairs.
zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result
-- | Takes two lists and combines them with a custom combining function
zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result
-- | Converts a list of pairs into two separate lists of elements
unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb)
-- | Evaluate each action, ignoring the results
sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()
-- | Converts to a MonadPlus instance
toMonadPlus :: (MonadPlus m, ListLike full a) => full -> m (a, full)
-- | List-like destructor (like Data.Maybe.maybe)
list :: ListLike full a => b -> (a -> full -> b) -> full -> b
-- | String-like functions
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.IO
-- | An extension to ListLike for those data types that support I/O.
-- These functions mirror those in System.IO for the most part.
-- They also share the same names; see the comments in
-- Data.ListLike for help importing them.
--
-- Note that some types may not be capable of lazy reading or writing.
-- Therefore, the usual semantics of System.IO functions regarding
-- laziness may or may not be available from a particular implementation.
--
-- Minimal complete definition:
--
--
-- - hGetLine
-- - hGetContents
-- - hGet
-- - hGetNonBlocking
-- - hPutStr
--
class ListLike full item => ListLikeIO full item | full -> item
hGetLine :: ListLikeIO full item => Handle -> IO full
hGetContents :: ListLikeIO full item => Handle -> IO full
hGet :: ListLikeIO full item => Handle -> Int -> IO full
hGetNonBlocking :: ListLikeIO full item => Handle -> Int -> IO full
hPutStr :: ListLikeIO full item => Handle -> full -> IO ()
hPutStrLn :: ListLikeIO full item => Handle -> full -> IO ()
getLine :: ListLikeIO full item => IO full
getContents :: ListLikeIO full item => IO full
putStr :: ListLikeIO full item => full -> IO ()
putStrLn :: ListLikeIO full item => full -> IO ()
interact :: ListLikeIO full item => (full -> full) -> IO ()
readFile :: ListLikeIO full item => FilePath -> IO full
writeFile :: ListLikeIO full item => FilePath -> full -> IO ()
appendFile :: ListLikeIO full item => FilePath -> full -> IO ()
-- | Instances of Data.ListLike.ListLike and related classes.
-- Re-exported by Data.ListLike.
--
-- Written by John Goerzen, jgoerzen@complete.org
module Data.ListLike.Instances
instance (Integral i, Ix i) => ListLikeIO (Array i Char) Char
instance (Integral i, Ix i) => StringLike (Array i Char)
instance (Integral i, Ix i) => ListLike (Array i e) e
instance (Integral i, Ix i) => Monoid (Array i e)
instance Ix i => FoldableLL (Array i e) e
instance (Ord key, Eq val) => ListLike (Map key val) (key, val)
instance Ord key => FoldableLL (Map key val) (key, val)
instance StringLike ByteString
instance ListLikeIO ByteString Word8
instance ListLike ByteString Word8
instance FoldableLL ByteString Word8
instance StringLike ByteString
instance ListLikeIO ByteString Word8
instance ListLike ByteString Word8
instance FoldableLL ByteString Word8
instance InfiniteListLike [a] a
instance StringLike String
instance ListLikeIO String Char
-- | Generic operations over list-like structures
--
-- Written by John Goerzen, jgoerzen@complete.org
--
-- Please start with the introduction at Data.ListLike#intro.
module Data.ListLike
-- | Returns True if all elements are True
and :: ListLike full Bool => full -> Bool
-- | Returns True if any element is True
or :: ListLike full Bool => full -> Bool
-- | The sum of the list
sum :: (Num a, ListLike full a) => full -> a
-- | The product of the list
product :: (Num a, ListLike full a) => full -> a
-- | Combine the elements of a structure using a monoid. fold =
-- foldMap id
fold :: (FoldableLL full item, Monoid item) => full -> item
-- | Map each element to a monoid, then combine the results
foldMap :: (FoldableLL full item, Monoid m) => (item -> m) -> full -> m
-- | Takes two lists and returns a list of corresponding pairs.
zip :: (ListLike full item, ListLike fullb itemb, ListLike result (item, itemb)) => full -> fullb -> result
-- | Takes two lists and combines them with a custom combining function
zipWith :: (ListLike full item, ListLike fullb itemb, ListLike result resultitem) => (item -> itemb -> resultitem) -> full -> fullb -> result
-- | Converts a list of pairs into two separate lists of elements
unzip :: (ListLike full (itema, itemb), ListLike ra itema, ListLike rb itemb) => full -> (ra, rb)
-- | Evaluate each action, ignoring the results
sequence_ :: (Monad m, ListLike mfull (m item)) => mfull -> m ()
-- | An extension to ListLike for those data types that support I/O.
-- These functions mirror those in System.IO for the most part.
-- They also share the same names; see the comments in
-- Data.ListLike for help importing them.
--
-- Note that some types may not be capable of lazy reading or writing.
-- Therefore, the usual semantics of System.IO functions regarding
-- laziness may or may not be available from a particular implementation.
--
-- Minimal complete definition:
--
--
-- - hGetLine
-- - hGetContents
-- - hGet
-- - hGetNonBlocking
-- - hPutStr
--
class ListLike full item => ListLikeIO full item | full -> item
hGetLine :: ListLikeIO full item => Handle -> IO full
hGetContents :: ListLikeIO full item => Handle -> IO full
hGet :: ListLikeIO full item => Handle -> Int -> IO full
hGetNonBlocking :: ListLikeIO full item => Handle -> Int -> IO full
hPutStr :: ListLikeIO full item => Handle -> full -> IO ()
hPutStrLn :: ListLikeIO full item => Handle -> full -> IO ()
getLine :: ListLikeIO full item => IO full
getContents :: ListLikeIO full item => IO full
putStr :: ListLikeIO full item => full -> IO ()
putStrLn :: ListLikeIO full item => full -> IO ()
interact :: ListLikeIO full item => (full -> full) -> IO ()
readFile :: ListLikeIO full item => FilePath -> IO full
writeFile :: ListLikeIO full item => FilePath -> full -> IO ()
appendFile :: ListLikeIO full item => FilePath -> full -> IO ()
-- | The class implementing list-like functions.
--
-- It is worth noting that types such as Data.Map.Map can be
-- instances of ListLike. Due to their specific ways of operating,
-- they may not behave in the expected way in some cases. For instance,
-- cons may not increase the size of a map if the key you have
-- given is already in the map; it will just replace the value already
-- there.
--
-- Implementators must define at least:
--
--
-- - singleton
-- - head
-- - tail
-- - null or genericLength
--
class (FoldableLL full item, Monoid full) => ListLike full item | full -> item
empty :: ListLike full item => full
singleton :: ListLike full item => item -> full
cons :: ListLike full item => item -> full -> full
snoc :: ListLike full item => full -> item -> full
append :: ListLike full item => full -> full -> full
head :: ListLike full item => full -> item
last :: ListLike full item => full -> item
tail :: ListLike full item => full -> full
init :: ListLike full item => full -> full
null :: ListLike full item => full -> Bool
length :: ListLike full item => full -> Int
map :: (ListLike full item, ListLike full' item') => (item -> item') -> full -> full'
rigidMap :: ListLike full item => (item -> item) -> full -> full
reverse :: ListLike full item => full -> full
intersperse :: ListLike full item => item -> full -> full
concat :: (ListLike full item, ListLike full' full, Monoid full) => full' -> full
concatMap :: (ListLike full item, ListLike full' item') => (item -> full') -> full -> full'
rigidConcatMap :: ListLike full item => (item -> full) -> full -> full
any :: ListLike full item => (item -> Bool) -> full -> Bool
all :: ListLike full item => (item -> Bool) -> full -> Bool
maximum :: (ListLike full item, Ord item) => full -> item
minimum :: (ListLike full item, Ord item) => full -> item
replicate :: ListLike full item => Int -> item -> full
take :: ListLike full item => Int -> full -> full
drop :: ListLike full item => Int -> full -> full
splitAt :: ListLike full item => Int -> full -> (full, full)
takeWhile :: ListLike full item => (item -> Bool) -> full -> full
dropWhile :: ListLike full item => (item -> Bool) -> full -> full
span :: ListLike full item => (item -> Bool) -> full -> (full, full)
break :: ListLike full item => (item -> Bool) -> full -> (full, full)
group :: (ListLike full item, ListLike full' full, Eq item) => full -> full'
inits :: (ListLike full item, ListLike full' full) => full -> full'
tails :: (ListLike full item, ListLike full' full) => full -> full'
isPrefixOf :: (ListLike full item, Eq item) => full -> full -> Bool
isSuffixOf :: (ListLike full item, Eq item) => full -> full -> Bool
isInfixOf :: (ListLike full item, Eq item) => full -> full -> Bool
elem :: (ListLike full item, Eq item) => item -> full -> Bool
notElem :: (ListLike full item, Eq item) => item -> full -> Bool
find :: ListLike full item => (item -> Bool) -> full -> Maybe item
filter :: ListLike full item => (item -> Bool) -> full -> full
partition :: ListLike full item => (item -> Bool) -> full -> (full, full)
index :: ListLike full item => full -> Int -> item
elemIndex :: (ListLike full item, Eq item) => item -> full -> Maybe Int
elemIndices :: (ListLike full item, Eq item, ListLike result Int) => item -> full -> result
findIndex :: ListLike full item => (item -> Bool) -> full -> Maybe Int
findIndices :: (ListLike full item, ListLike result Int) => (item -> Bool) -> full -> result
sequence :: (ListLike full item, Monad m, ListLike fullinp (m item)) => fullinp -> m full
mapM :: (ListLike full item, Monad m, ListLike full' item') => (item -> m item') -> full -> m full'
rigidMapM :: (ListLike full item, Monad m) => (item -> m item) -> full -> m full
mapM_ :: (ListLike full item, Monad m) => (item -> m b) -> full -> m ()
nub :: (ListLike full item, Eq item) => full -> full
delete :: (ListLike full item, Eq item) => item -> full -> full
deleteFirsts :: (ListLike full item, Eq item) => full -> full -> full
union :: (ListLike full item, Eq item) => full -> full -> full
intersect :: (ListLike full item, Eq item) => full -> full -> full
sort :: (ListLike full item, Ord item) => full -> full
insert :: (ListLike full item, Ord item) => item -> full -> full
toList :: ListLike full item => full -> [item]
fromList :: ListLike full item => [item] -> full
fromListLike :: (ListLike full item, ListLike full' item) => full -> full'
nubBy :: ListLike full item => (item -> item -> Bool) -> full -> full
deleteBy :: ListLike full item => (item -> item -> Bool) -> item -> full -> full
deleteFirstsBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
unionBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
intersectBy :: ListLike full item => (item -> item -> Bool) -> full -> full -> full
groupBy :: (ListLike full item, ListLike full' full, Eq item) => (item -> item -> Bool) -> full -> full'
sortBy :: (ListLike full item, Ord item) => (item -> item -> Ordering) -> full -> full
insertBy :: (ListLike full item, Ord item) => (item -> item -> Ordering) -> item -> full -> full
genericLength :: (ListLike full item, Num a) => full -> a
genericTake :: (ListLike full item, Integral a) => a -> full -> full
genericDrop :: (ListLike full item, Integral a) => a -> full -> full
genericSplitAt :: (ListLike full item, Integral a) => a -> full -> (full, full)
genericReplicate :: (ListLike full item, Integral a) => a -> item -> full
-- | This is the primary class for structures that are to be considered
-- foldable. A minimum complete definition provides foldl and
-- foldr.
--
-- Instances of FoldableLL can be folded, and can be many and
-- varied.
--
-- These functions are used heavily in Data.ListLike.
class FoldableLL full item | full -> item
foldl :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
foldl' :: FoldableLL full item => (a -> item -> a) -> a -> full -> a
foldl1 :: FoldableLL full item => (item -> item -> item) -> full -> item
foldr :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
foldr' :: FoldableLL full item => (item -> b -> b) -> b -> full -> b
foldr1 :: FoldableLL full item => (item -> item -> item) -> full -> item
-- | An extension to ListLike for those data types that are similar
-- to a String. Minimal complete definition is toString and
-- fromString.
class StringLike s
toString :: StringLike s => s -> String
fromString :: StringLike s => String -> s
lines :: (StringLike s, ListLike full s) => s -> full
words :: (StringLike s, ListLike full s) => s -> full
-- | An extension to ListLike for those data types that are capable
-- of dealing with infinite lists. Some ListLike functions are
-- capable of working with finite or infinite lists. The functions here
-- require infinite list capability in order to work at all.
class ListLike full item => InfiniteListLike full item | full -> item
iterate :: InfiniteListLike full item => (item -> item) -> item -> full
repeat :: InfiniteListLike full item => item -> full
cycle :: InfiniteListLike full item => full -> full