-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Abstractions over deferred folds
--   
--   This library is in an experimental state. Users should be prepared for
--   frequent updates.
@package deferred-folds
@version 0.9.18.7

module DeferredFolds.Unfoldl

-- | Filter the values given a predicate
filter :: (a -> Bool) -> Unfoldl a -> Unfoldl a

-- | Apply a Gonzalez fold
fold :: Fold input output -> Unfoldl input -> output

-- | A projection on data, which only knows how to execute a strict
--   left-fold.
--   
--   It is a monad and a monoid, and is very useful for efficiently
--   aggregating the projections on data intended for left-folding, since
--   its concatenation (<>) has complexity of O(1).
--   
--   
--   
- Intuition
--   
--   
--   The intuition for this abstraction can be derived from lists.
--   
--   Let's consider the foldl' function for lists:
--   
--   
--   foldl' :: (b -> a -> b) -> b -> [a] -> b
--   
--   
--   If we rearrange its parameters we get
--   
--   
--   foldl' :: [a] -> (b -> a -> b) -> b -> b
--   
--   
--   Which in Haskell is essentially the same as
--   
--   
--   foldl' :: [a] -> (forall b. (b -> a -> b) -> b -> b)
--   
--   
--   We can isolate that part into an abstraction:
--   
--   
--   newtype Unfoldl a = Unfoldl (forall b. (b -> a -> b) -> b -> b)
--   
--   
--   Then we get to this simple morphism:
--   
--   
--   list :: [a] -> Unfoldl a
--   list list = Unfoldl (\ step init -> foldl' step init list)
--   
--   
--   We can do the same with say Data.Text.Text:
--   
--   
--   text :: Text -> Unfoldl Char
--   text text = Unfoldl (\ step init -> Data.Text.foldl' step init text)
--   
--   
--   And then we can use those both to concatenate with just an
--   O(1) cost:
--   
--   
--   abcdef :: Unfoldl Char
--   abcdef = list ['a', 'b', 'c'] <> text "def"
--   
--   
--   Please notice that up until this moment no actual data materialization
--   has happened and hence no traversals have appeared. All that we've
--   done is just composed a function, which only specifies which parts of
--   data structures to traverse to perform a left-fold. Only at the moment
--   where the actual folding will happen will we actually traverse the
--   source data. E.g., using the "fold" function:
--   
--   
--   abcdefLength :: Int
--   abcdefLength = fold Control.Foldl.length abcdef
--   
newtype Unfoldl a
Unfoldl :: (forall x. () => (x -> a -> x) -> x -> x) -> Unfoldl a

-- | Construct from any foldable
foldable :: Foldable foldable => foldable a -> Unfoldl a

-- | Ints in the specified inclusive range
intsInRange :: Int -> Int -> Unfoldl Int

-- | Bytes of a bytestring
byteStringBytes :: ByteString -> Unfoldl Word8

-- | Bytes of a short bytestring
shortByteStringBytes :: ShortByteString -> Unfoldl Word8

-- | Elements of a prim array
primArray :: Prim prim => PrimArray prim -> Unfoldl prim

-- | Elements of a prim array coming paired with indices
primArrayWithIndices :: Prim prim => PrimArray prim -> Unfoldl (Int, prim)

-- | Unlift a monadic unfold
unfoldlM :: UnfoldlM Identity input -> Unfoldl input

-- | Lift a fold input mapping function into a mapping of unfolds
mapFoldInput :: (forall x. () => Fold b x -> Fold a x) -> Unfoldl a -> Unfoldl b

-- | Associations of a map
mapAssocs :: Map key value -> Unfoldl (key, value)

-- | Associations of an intmap
intMapAssocs :: IntMap value -> Unfoldl (Int, value)

module DeferredFolds.UnfoldlM
unfoldr :: forall (m :: Type -> Type) a. Monad m => Unfoldr a -> UnfoldlM m a

-- | Filter the values given a predicate
filter :: Monad m => (a -> m Bool) -> UnfoldlM m a -> UnfoldlM m a

-- | Check whether it's empty
null :: Monad m => UnfoldlM m input -> m Bool

-- | Apply a Gonzalez fold
fold :: Fold input output -> UnfoldlM Identity input -> output

-- | A more efficient implementation of mapM_
mapM_ :: Monad m => (input -> m ()) -> UnfoldlM m input -> m ()

-- | Same as mapM_ with arguments flipped
forM_ :: Monad m => UnfoldlM m input -> (input -> m ()) -> m ()

-- | Apply a monadic Gonzalez fold
foldM :: Monad m => FoldM m input output -> UnfoldlM m input -> m output

-- | Change the base monad using invariant natural transformations
hoist :: (forall a1. () => m a1 -> n a1) -> (forall a1. () => n a1 -> m a1) -> UnfoldlM m a -> UnfoldlM n a

-- | Perform a monadic strict left fold
foldlM' :: Monad m => (output -> input -> m output) -> output -> UnfoldlM m input -> m output

-- | A monadic variation of DeferredFolds.Unfoldl
newtype UnfoldlM (m :: Type -> Type) a
UnfoldlM :: (forall x. () => (x -> a -> m x) -> x -> m x) -> UnfoldlM (m :: Type -> Type) a

-- | Construct from any foldable
foldable :: forall (m :: Type -> Type) foldable a. (Monad m, Foldable foldable) => foldable a -> UnfoldlM m a

-- | Lift a fold input mapping function into a mapping of unfolds
mapFoldMInput :: forall (m :: Type -> Type) b a. Monad m => (forall x. () => FoldM m b x -> FoldM m a x) -> UnfoldlM m a -> UnfoldlM m b

-- | Construct from a specification of how to execute a left-fold
foldlRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. () => (x -> a -> x) -> x -> x) -> UnfoldlM m a

-- | Construct from a specification of how to execute a right-fold
foldrRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. () => (a -> x -> x) -> x -> x) -> UnfoldlM m a

-- | Ints in the specified inclusive range
intsInRange :: forall (m :: Type -> Type). Monad m => Int -> Int -> UnfoldlM m Int

-- | TVar contents
tVarValue :: TVar a -> UnfoldlM STM a

-- | Bytes of a bytestring
byteStringBytes :: ByteString -> UnfoldlM IO Word8

-- | Bytes of a short bytestring
shortByteStringBytes :: forall (m :: Type -> Type). Monad m => ShortByteString -> UnfoldlM m Word8

-- | Elements of a prim array
primArray :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m prim

-- | Elements of a prim array coming paired with indices
primArrayWithIndices :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m (Int, prim)

module DeferredFolds.Unfoldr

-- | Elements of a vector
vector :: Vector vector a => vector a -> Unfoldr a

-- | Filter the values given a predicate
filter :: (a -> Bool) -> Unfoldr a -> Unfoldr a
takeWhile :: (a -> Bool) -> Unfoldr a -> Unfoldr a
take :: Int -> Unfoldr a -> Unfoldr a

-- | Reverse the order.
--   
--   Use with care, because it requires to allocate all elements.
reverse :: Unfoldr a -> Unfoldr a
zipWith :: (a -> b -> c) -> Unfoldr a -> Unfoldr b -> Unfoldr c

-- | Apply a Gonzalez fold
fold :: Fold input output -> Unfoldr input -> output

-- | Insert a separator value between each element.
--   
--   Behaves the same way as intersperse.
intersperse :: a -> Unfoldr a -> Unfoldr a

-- | Apply a monadic Gonzalez fold
foldM :: Monad m => FoldM m input output -> Unfoldr input -> m output
cons :: a -> Unfoldr a -> Unfoldr a
snoc :: a -> Unfoldr a -> Unfoldr a

-- | A projection on data, which only knows how to execute a right-fold.
--   
--   It is a monad and a monoid, and is very useful for efficiently
--   aggregating the projections on data intended for right-folding, since
--   its concatenation (<>) has complexity of O(1).
--   
--   
--   
- Intuition
--   
--   
--   The intuition of what this abstraction is all about can be derived
--   from lists.
--   
--   Let's consider the foldr function for lists:
--   
--   
--   foldr :: (a -> b -> b) -> b -> [a] -> b
--   
--   
--   If we rearrange its parameters we get
--   
--   
--   foldr :: [a] -> (a -> b -> b) -> b -> b
--   
--   
--   Which in Haskell is essentially the same as
--   
--   
--   foldr :: [a] -> (forall b. (a -> b -> b) -> b -> b)
--   
--   
--   We can isolate that part into an abstraction:
--   
--   
--   newtype Unfoldr a = Unfoldr (forall b. (a -> b -> b) -> b -> b)
--   
--   
--   Then we get to this simple morphism:
--   
--   
--   list :: [a] -> Unfoldr a
--   list list = Unfoldr (\ step init -> foldr step init list)
--   
--   
--   We can do the same with say Data.Text.Text:
--   
--   
--   text :: Text -> Unfoldr Char
--   text text = Unfoldr (\ step init -> Data.Text.foldr step init text)
--   
--   
--   And then we can use those both to concatenate with just an
--   O(1) cost:
--   
--   
--   abcdef :: Unfoldr Char
--   abcdef = list ['a', 'b', 'c'] <> text "def"
--   
--   
--   Please notice that up until this moment no actual data materialization
--   has happened and hence no traversals have appeared. All that we've
--   done is just composed a function, which only specifies which parts of
--   data structures to traverse to perform a right-fold. Only at the
--   moment where the actual folding will happen will we actually traverse
--   the source data. E.g., using the "fold" function:
--   
--   
--   abcdefLength :: Int
--   abcdefLength = fold Control.Foldl.length abcdef
--   
newtype Unfoldr a
Unfoldr :: (forall x. () => (a -> x -> x) -> x -> x) -> Unfoldr a

-- | Construct from any foldable
foldable :: Foldable foldable => foldable a -> Unfoldr a

-- | Ints in the specified inclusive range
intsInRange :: Int -> Int -> Unfoldr Int

-- | Bytes of a bytestring
byteStringBytes :: ByteString -> Unfoldr Word8

-- | Bytes of a short bytestring
shortByteStringBytes :: ShortByteString -> Unfoldr Word8

-- | Elements of a prim array
primArray :: Prim prim => PrimArray prim -> Unfoldr prim

-- | Elements of a prim array coming paired with indices
primArrayWithIndices :: Prim prim => PrimArray prim -> Unfoldr (Int, prim)

-- | Associations of a map
mapAssocs :: Map key value -> Unfoldr (key, value)

-- | Associations of an intmap
intMapAssocs :: IntMap value -> Unfoldr (Int, value)

-- | Elements of IntSet.
intSet :: IntSet -> Unfoldr Int

-- | Ascending infinite stream of enums starting from the one specified
enumsFrom :: Enum a => a -> Unfoldr a

-- | Enums in the specified inclusive range
enumsInRange :: (Enum a, Ord a) => a -> a -> Unfoldr a

-- | Ascending infinite stream of ints starting from the one specified
intsFrom :: Int -> Unfoldr Int

-- | Keys of a hash-map
hashMapKeys :: HashMap key value -> Unfoldr key

-- | Associations of a hash-map
hashMapAssocs :: HashMap key value -> Unfoldr (key, value)

-- | Value of a hash-map by key
hashMapAt :: (Hashable key, Eq key) => HashMap key value -> key -> Unfoldr value

-- | Value of a hash-map by key

-- | Deprecated: Use hashMapAt instead
hashMapValue :: (Hashable key, Eq key) => key -> HashMap key value -> Unfoldr value

-- | Values of a hash-map by their keys
hashMapValues :: (Hashable key, Eq key) => HashMap key value -> Unfoldr key -> Unfoldr value

-- | Elements of a vector coming paired with indices
vectorWithIndices :: Vector vector a => vector a -> Unfoldr (Int, a)

-- | Binary digits of a non-negative integral number.
binaryDigits :: Integral a => a -> Unfoldr a

-- | Binary digits of a non-negative integral number in reverse order.
reverseBinaryDigits :: Integral a => a -> Unfoldr a

-- | Digits of a non-negative number in numeral system based on the
--   specified radix. The digits come in reverse order.
--   
--   E.g., here's how an unfold of binary digits in proper order looks:
--   
--   
--   binaryDigits :: Integral a => a -> Unfoldr a
--   binaryDigits = reverse . reverseDigits 2
--   
reverseDigits :: Integral a => a -> a -> Unfoldr a

-- | Octal digits of a non-negative integral number.
octalDigits :: Integral a => a -> Unfoldr a

-- | Octal digits of a non-negative integral number in reverse order.
reverseOctalDigits :: Integral a => a -> Unfoldr a

-- | Decimal digits of a non-negative integral number.
decimalDigits :: Integral a => a -> Unfoldr a

-- | Decimal digits of a non-negative integral number in reverse order.
--   More efficient than decimalDigits.
reverseDecimalDigits :: Integral a => a -> Unfoldr a

-- | Hexadecimal digits of a non-negative number.
hexadecimalDigits :: Integral a => a -> Unfoldr a

-- | Hexadecimal digits of a non-negative number in reverse order.
reverseHexadecimalDigits :: Integral a => a -> Unfoldr a

-- | Lift into an unfold, which produces pairs with index.
zipWithIndex :: Unfoldr a -> Unfoldr (Int, a)

-- | Lift into an unfold, which produces pairs with right-associative
--   index.

-- | Deprecated: This function builds up stack. Use zipWithIndex
--   instead.
zipWithReverseIndex :: Unfoldr a -> Unfoldr (Int, a)

-- | Indices of set bits.
setBitIndices :: FiniteBits a => a -> Unfoldr Int

-- | Indices of unset bits.
unsetBitIndices :: FiniteBits a => a -> Unfoldr Int

-- | Reproduces the behaviour of unpack.
--   
--   Implementation is efficient and avoids allocation of an intermediate
--   list.
textChars :: Text -> Unfoldr Char

-- | Reproduces the behaviour of words.
--   
--   Implementation is efficient and avoids allocation of an intermediate
--   list.
textWords :: Text -> Unfoldr Text

-- | Transformer of chars, replaces all space-like chars with space, all
--   newline-like chars with \n, and trims their duplicate
--   sequences to single-char. Oh yeah, it also trims whitespace from
--   beginning and end.
trimWhitespace :: Unfoldr Char -> Unfoldr Char
