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

-- | Group streams into substreams
--   
--   pipes-group uses FreeT and lenses to group streams
--   into sub-streams. Notable features include:
--   
--   
--   
- Perfect Streaming: Group elements without collecting them
--   into memory
--   
- Lens Support: Use lenses to simplify many common
--   operations
--   
--   
--   Pipes.Group contains the full documentation for this library.
--   
--   Read Pipes.Group.Tutorial for an extensive tutorial.
@package pipes-group
@version 1.0.12

-- | Element-agnostic grouping utilities for pipes
--   
--   See Pipes.Group.Tutorial for an extended tutorial
--   
--   Some type signatures below refer to the aliases below, which are not
--   used in this library, but are included to simplify the documentation.
--   
--   
--   type Groups         a m x = FreeT (Producer a m) m x
--   type Splitter       a m x = Producer a m x -> Groups a m x
--   type Transformation a m x = Groups a m x -> Groups a m x
--   type Joiner         a m x = Groups a m x -> Producer a m x
--   
module Pipes.Group

-- | Like groupsBy, where the equality predicate is (==)
--   
--   
--        groups :: Monad m => Lens' (Producer a m x) (Groups a m x)
--   view groups :: Monad m => Splitter a m x
--   set  groups :: Monad m => Groups a m x -> Producer a m x -> Producer a m x
--   over groups :: Monad m => Transformation a m x -> Producer a m x -> Producer a m x
--   
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> (toList . intercalates (yield '|') . view groups) (each "12233345")
--   "1|22|333|4|5"
--   
groups :: forall (m :: Type -> Type) a' x a. (Monad m, Eq a') => Lens (Producer a' m x) (Producer a m x) (FreeT (Producer a' m) m x) (FreeT (Producer a m) m x)

-- | groupsBy splits a Producer into a FreeT of
--   Producers grouped using the given equality predicate
--   
--   
--         groupsBy p  :: Monad m => Lens' (Producer a m x) (Groups a m x)
--   view (groupsBy p) :: Monad m => Splitter a m x
--   set  (groupsBy p) :: Monad m => Groups a m x -> Producer a m x -> Producer a m x
--   over (groupsBy p) :: Monad m => Transformation a m x -> Producer a m x -> Producer a m x
--   
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> (toList . intercalates (yield '|') . view (groupsBy (==))) (each "12233345")
--   "1|22|333|4|5"
--   
groupsBy :: forall (m :: Type -> Type) a' x a. Monad m => (a' -> a' -> Bool) -> Lens (Producer a' m x) (Producer a m x) (FreeT (Producer a' m) m x) (FreeT (Producer a m) m x)

-- | groupsBy' splits a Producer into a FreeT of
--   Producers grouped using the given equality predicate
--   
--   This differs from groupsBy by comparing successive elements for
--   equality instead of comparing each element to the first member of the
--   group
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> let cmp c1 c2 = succ c1 == c2
--   
--   >>> (toList . intercalates (yield '|') . view (groupsBy' cmp)) (each "12233345")
--   "12|23|3|345"
--   
--   >>> (toList . intercalates (yield '|') . view (groupsBy  cmp)) (each "12233345")
--   "122|3|3|34|5"
--   
--   
--   
--         groupsBy' p  :: Monad m => Lens' (Producer a m x) (Groups a m x)
--   view (groupsBy' p) :: Monad m => Splitter a m x
--   set  (groupsBy' p) :: Monad m => Groups a m x -> Producer a m x -> Producer a m x
--   over (groupsBy' p) :: Monad m => Transformation a m x -> Producer a m x -> Producer a m x
--   
groupsBy' :: forall (m :: Type -> Type) a' x a. Monad m => (a' -> a' -> Bool) -> Lens (Producer a' m x) (Producer a m x) (FreeT (Producer a' m) m x) (FreeT (Producer a m) m x)

-- | chunksOf is an splits a Producer into a FreeT of
--   Producers of fixed length
--   
--   
--         chunksOf n  :: Monad m => Lens' (Producer a m x) (Groups a m x)
--   view (chunksOf n) :: Monad m => Splitter a m x
--   set  (chunksOf n) :: Monad m => Groups a m x -> Producer a m x -> Producer a m x
--   over (chunksOf n) :: Monad m => Transformation a m x -> Producer a m x -> Producer a m x
--   
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> (toList . intercalates (yield '|') . view (chunksOf 3)) (each "12233345")
--   "122|333|45"
--   
chunksOf :: forall (m :: Type -> Type) a' x a. Monad m => Int -> Lens (Producer a' m x) (Producer a m x) (FreeT (Producer a' m) m x) (FreeT (Producer a m) m x)

-- | (takes n) only keeps the first n functor layers of a
--   FreeT
--   
--   
--   takes :: Monad m => Int -> Groups a m () -> Groups a m ()
--   
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> (toList . intercalates (yield '|') . takes 3 . view groups) (each "12233345")
--   "1|22|333"
--   
takes :: forall (f :: Type -> Type) (m :: Type -> Type). (Functor f, Monad m) => Int -> FreeT f m () -> FreeT f m ()

-- | (takes' n) only keeps the first n Producers
--   of a FreeT
--   
--   takes' differs from takes by draining unused
--   Producers in order to preserve the return value. This makes it
--   a suitable argument for maps.
--   
--   
--   takes' :: Monad m => Int -> Transformation a m x
--   
takes' :: forall (m :: Type -> Type) a x. Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x

-- | (drops n) peels off the first n Producer
--   layers of a FreeT
--   
--   
--   drops :: Monad m => Int -> Transformation a m x
--   
--   
--   
--   >>> import Lens.Family (view)
--   
--   >>> import Pipes (yield, each)
--   
--   >>> import Pipes.Prelude (toList)
--   
--   >>> (toList . intercalates (yield '|') . drops 3 . view groups) (each "12233345")
--   "4|5"
--   
--   
--   Use carefully: the peeling off is not free. This runs the first
--   n layers, just discarding everything they produce.
drops :: forall (m :: Type -> Type) a x. Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x

-- | Transform each individual functor layer of a FreeT
--   
--   You can think of this as:
--   
--   
--   maps
--       :: (forall r . Producer a m r -> Producer b m r)
--       -> FreeT (Producer a m) m x -> FreeT (Producer b m) m x
--   
--   
--   This is just a synonym for transFreeT
maps :: forall (m :: Type -> Type) g f x. (Monad m, Functor g) => (forall r. () => f r -> g r) -> FreeT f m x -> FreeT g m x

-- | Lens to transform each individual functor layer of a FreeT.
--   (over individually) is equivalent to maps, but
--   with a less general type.
--   
--   
--   type Group a m x = Producer a m (Groups a m x)
--   
--   set  individually :: Monad m => Group a m x -> Transformation a m x
--   over individually :: Monad m => (Group a m x -> Group a m x) -> Transformation a m x
--   
individually :: forall (m :: Type -> Type) g f x. (Monad m, Functor g) => Setter (FreeT f m x) (FreeT g m x) (f (FreeT f m x)) (g (FreeT f m x))

-- | Join a FreeT-delimited stream of Producers into a single
--   Producer
--   
--   
--   concats :: Monad m => Joiner a m x
--   
concats :: forall (m :: Type -> Type) a x. Monad m => FreeT (Producer a m) m x -> Producer a m x

-- | Join a FreeT-delimited stream of Producers into a single
--   Producer by intercalating a Producer in between them
--   
--   
--   intercalates :: Monad m => Producer a m () -> Joiner a m x
--   
intercalates :: forall (m :: Type -> Type) a x. Monad m => Producer a m () -> FreeT (Producer a m) m x -> Producer a m x

-- | Fold each Producer of a FreeT
--   
--   
--   purely folds :: Monad m => Fold a b -> Groups a m r -> Producer b m r
--   
folds :: forall (m :: Type -> Type) x a b r. Monad m => (x -> a -> x) -> x -> (x -> b) -> FreeT (Producer a m) m r -> Producer b m r

-- | Fold each Producer of a FreeT, monadically
--   
--   
--   impurely foldsM :: Monad m => FoldM a b -> Groups a m r -> Producer b m r
--   
foldsM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> FreeT (Producer a m) m r -> Producer b m r

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a

-- | The base functor for a free monad.
data FreeF (f :: Type -> Type) a b
Pure :: a -> FreeF (f :: Type -> Type) a b
Free :: f b -> FreeF (f :: Type -> Type) a b

-- | The "free monad transformer" for a functor f
newtype FreeT (f :: Type -> Type) (m :: Type -> Type) a
FreeT :: m (FreeF f a (FreeT f m a)) -> FreeT (f :: Type -> Type) (m :: Type -> Type) a
[runFreeT] :: FreeT (f :: Type -> Type) (m :: Type -> Type) a -> m (FreeF f a (FreeT f m a))

-- | Produce a value
--   
--   
--   yield :: Monad m => a -> Producer a m ()
--   yield :: Monad m => a -> Pipe   x a m ()
--   
yield :: forall (m :: Type -> Type) a x' x. Functor m => a -> Proxy x' x () a m ()

-- | Producers can only yield
type Producer b = Proxy X () () b

-- | Consume the first value from a Producer
--   
--   next either fails with a Left if the Producer
--   terminates or succeeds with a Right providing the next value
--   and the remainder of the Producer.
next :: Monad m => Producer a m r -> m (Either r (a, Producer a m r))

-- | pipes-group builds upon pipes to establish idioms
--   for grouping streams into sub-streams without collecting elements into
--   memory. This tutorial assumes familiarity with pipes and
--   pipes-parse.
module Pipes.Group.Tutorial
