pipes-group-1.0.12: Group streams into substreams

Safe Haskell | Safe-Inferred
Language | Haskell2010

Pipes.Group

Contents

- Lenses
- Transformations
- Joiners
- Folds
- Re-exports

Description

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

Synopsis

- groups :: (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 :: 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' :: 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 :: 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 :: (Functor f, Monad m) => Int -> FreeT f m () -> FreeT f m ()
- takes' :: Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x
- drops :: Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x
- maps :: (Monad m, Functor g) => (forall r. f r -> g r) -> FreeT f m x -> FreeT g m x
- individually :: (Monad m, Functor g) => Setter (FreeT f m x) (FreeT g m x) (f (FreeT f m x)) (g (FreeT f m x))
- concats :: Monad m => FreeT (Producer a m) m x -> Producer a m x
- intercalates :: Monad m => Producer a m () -> FreeT (Producer a m) m x -> Producer a m x
- folds :: Monad m => (x -> a -> x) -> x -> (x -> b) -> FreeT (Producer a m) 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 :: (MonadTrans t, Monad m) => m a -> t m a
- newtype FreeT (f :: Type -> Type) (m :: Type -> Type) a = FreeT {
  - runFreeT :: m (FreeF f a (FreeT f m a))
  }
- data FreeF (f :: Type -> Type) a b
  - = Pure a
  - | Free (f b)
- type Producer b = Proxy X () () b
- yield :: forall (m :: Type -> Type) a x' x. Functor m => a -> Proxy x' x () a m ()
- next :: Monad m => Producer a m r -> m (Either r (a, Producer a m r))

# Lenses

groups :: (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) Source #

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"

groupsBy :: 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) Source #

`groupsBy` splits a `Producer` into a `FreeT` of `Producer`s 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' :: 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) Source #

`groupsBy'` splits a `Producer` into a `FreeT` of `Producer`s 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

chunksOf :: Monad m => Int -> Lens (Producer a' m x) (Producer a m x) (FreeT (Producer a' m) m x) (FreeT (Producer a m) m x) Source #

`chunksOf` is an splits a `Producer` into a `FreeT` of `Producer`s 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"

# Transformations

takes :: (Functor f, Monad m) => Int -> FreeT f m () -> FreeT f m () Source #

`(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' :: Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x Source #

`(takes' n)` only keeps the first `n` `Producer`s of a `FreeT`

`takes'` differs from `takes` by draining unused `Producer`s in order to preserve the return value. This makes it a suitable argument for `maps`.

    takes' :: Monad m => Int -> Transformation a m x

drops :: Monad m => Int -> FreeT (Producer a m) m x -> FreeT (Producer a m) m x Source #

`(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.

maps :: (Monad m, Functor g) => (forall r. f r -> g r) -> FreeT f m x -> FreeT g m x Source #

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`

individually :: (Monad m, Functor g) => Setter (FreeT f m x) (FreeT g m x) (f (FreeT f m x)) (g (FreeT f m x)) Source #

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

# Joiners

concats :: Monad m => FreeT (Producer a m) m x -> Producer a m x Source #

Join a `FreeT`-delimited stream of `Producer`s into a single `Producer`

    concats :: Monad m => Joiner a m x

intercalates :: Monad m => Producer a m () -> FreeT (Producer a m) m x -> Producer a m x Source #

Join a `FreeT`-delimited stream of `Producer`s into a single `Producer` by intercalating a `Producer` in between them

    intercalates :: Monad m => Producer a m () -> Joiner a m x

# Folds

These folds are designed to be compatible with the `foldl` library. See the `purely` and `impurely` functions from that library for more details.

For example, to count the number of `Producer` layers in a `FreeT`, you can write:

    import Control.Applicative (pure)
    import qualified Control.Foldl as L
    import Pipes.Group
    import qualified Pipes.Prelude as P

    count :: Monad m => FreeT (Producer a m) m () -> m Int
    count = P.sum . L.purely folds (pure 1)

folds Source #

Arguments

:: Monad m |
=> (x -> a -> x) | Step function
-> x | Initial accumulator
-> (x -> b) | Extraction function
-> FreeT (Producer a m) m r |
-> Producer b m r |

Fold each `Producer` of a `FreeT`

    purely folds :: Monad m => Fold a b -> Groups a m r -> Producer b m r

foldsM Source #

Arguments

:: Monad m |
=> (x -> a -> m x) | Step function
-> m x | Initial accumulator
-> (x -> m b) | Extraction function
-> 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

# Re-exports

Control.Monad.Trans.Class re-exports `lift`.

Control.Monad.Trans.Free re-exports `FreeF` and `FreeT`

Pipes re-exports `Producer`, `yield`, and `next`.

lift :: (MonadTrans t, Monad m) => m a -> t m a Source #

Lift a computation from the argument monad to the constructed monad.

newtype FreeT (f :: Type -> Type) (m :: Type -> Type) a Source #

The "free monad transformer" for a functor `f`

Constructors

FreeT |

Fields

- runFreeT :: m (FreeF f a (FreeT f m a))

#### Instances

Instances details

(Functor f, Monad m) => MonadFree f (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods wrap :: f (FreeT f m a) -> FreeT f m a Source #
(Functor f, MonadError e m) => MonadError e (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods throwError :: e -> FreeT f m a Source # catchError :: FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a Source #
(Functor f, MonadReader r m) => MonadReader r (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods ask :: FreeT f m r Source # local :: (r -> r) -> FreeT f m a -> FreeT f m a Source # reader :: (r -> a) -> FreeT f m a Source #
(Functor f, MonadState s m) => MonadState s (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods get :: FreeT f m s Source # put :: s -> FreeT f m () Source # state :: (s -> (a, s)) -> FreeT f m a Source #
(Functor f, MonadWriter w m) => MonadWriter w (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods writer :: (a, w) -> FreeT f m a Source # tell :: w -> FreeT f m () Source # listen :: FreeT f m a -> FreeT f m (a, w) Source # pass :: FreeT f m (a, w -> w) -> FreeT f m a Source #
(Functor f, MonadBase b m) => MonadBase b (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftBase :: b α -> FreeT f m α
Functor f => MonadTrans (FreeT f) |
Instance details Defined in Control.Monad.Trans.Free Methods lift :: Monad m => m a -> FreeT f m a Source #
(Functor f, MonadFail m) => MonadFail (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods fail :: String -> FreeT f m a Source #
(Functor f, MonadIO m) => MonadIO (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftIO :: IO a -> FreeT f m a Source #
(Foldable m, Foldable f) => Foldable (FreeT f m) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

fold :: Monoid m0 => FreeT f m m0 -> m0 Source #

foldMap :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source #

foldMap' :: Monoid m0 => (a -> m0) -> FreeT f m a -> m0 Source #

foldr :: (a -> b -> b) -> b -> FreeT f m a -> b Source #

foldr' :: (a -> b -> b) -> b -> FreeT f m a -> b Source #

foldl :: (b -> a -> b) -> b -> FreeT f m a -> b Source #

foldl' :: (b -> a -> b) -> b -> FreeT f m a -> b Source #

foldr1 :: (a -> a -> a) -> FreeT f m a -> a Source #

foldl1 :: (a -> a -> a) -> FreeT f m a -> a Source #

toList :: FreeT f m a -> [a] Source #

null :: FreeT f m a -> Bool Source #

length :: FreeT f m a -> Int Source #

elem :: Eq a => a -> FreeT f m a -> Bool Source #

maximum :: Ord a => FreeT f m a -> a Source #

minimum :: Ord a => FreeT f m a -> a Source #

sum :: Num a => FreeT f m a -> a Source #

product :: Num a => FreeT f m a -> a Source #

(Eq1 f, Eq1 m) => Eq1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftEq :: (a -> b -> Bool) -> FreeT f m a -> FreeT f m b -> Bool Source #
(Ord1 f, Ord1 m) => Ord1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftCompare :: (a -> b -> Ordering) -> FreeT f m a -> FreeT f m b -> Ordering Source #
(Read1 f, Read1 m) => Read1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (FreeT f m a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [FreeT f m a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (FreeT f m a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [FreeT f m a] Source #
(Show1 f, Show1 m) => Show1 (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> FreeT f m a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [FreeT f m a] -> ShowS Source #
(Monad m, Traversable m, Traversable f) => Traversable (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods traverse :: Applicative f0 => (a -> f0 b) -> FreeT f m a -> f0 (FreeT f m b) Source # sequenceA :: Applicative f0 => FreeT f m (f0 a) -> f0 (FreeT f m a) Source # mapM :: Monad m0 => (a -> m0 b) -> FreeT f m a -> m0 (FreeT f m b) Source # sequence :: Monad m0 => FreeT f m (m0 a) -> m0 (FreeT f m a) Source #
(Functor f, MonadPlus m) => Alternative (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods empty :: FreeT f m a Source # (<|>) :: FreeT f m a -> FreeT f m a -> FreeT f m a Source # some :: FreeT f m a -> FreeT f m [a] Source # many :: FreeT f m a -> FreeT f m [a] Source #
(Functor f, Monad m) => Applicative (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods pure :: a -> FreeT f m a Source # (<*>) :: FreeT f m (a -> b) -> FreeT f m a -> FreeT f m b Source # liftA2 :: (a -> b -> c) -> FreeT f m a -> FreeT f m b -> FreeT f m c Source # (*>) :: FreeT f m a -> FreeT f m b -> FreeT f m b Source # (<*) :: FreeT f m a -> FreeT f m b -> FreeT f m a Source #
(Functor f, Functor m) => Functor (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods fmap :: (a -> b) -> FreeT f m a -> FreeT f m b Source # (<$) :: a -> FreeT f m b -> FreeT f m a Source #
(Functor f, Monad m) => Monad (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (>>=) :: FreeT f m a -> (a -> FreeT f m b) -> FreeT f m b Source # (>>) :: FreeT f m a -> FreeT f m b -> FreeT f m b Source # return :: a -> FreeT f m a Source #
(Functor f, MonadPlus m) => MonadPlus (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods mzero :: FreeT f m a Source # mplus :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #
(Functor f, MonadCatch m) => MonadCatch (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods catch :: (HasCallStack, Exception e) => FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a Source #
(Functor f, MonadThrow m) => MonadThrow (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods throwM :: (HasCallStack, Exception e) => e -> FreeT f m a Source #
(Functor f, MonadCont m) => MonadCont (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods callCC :: ((a -> FreeT f m b) -> FreeT f m a) -> FreeT f m a Source #
(Functor f, Monad m) => Apply (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (<.>) :: FreeT f m (a -> b) -> FreeT f m a -> FreeT f m b (.>) :: FreeT f m a -> FreeT f m b -> FreeT f m b (<.) :: FreeT f m a -> FreeT f m b -> FreeT f m a liftF2 :: (a -> b -> c) -> FreeT f m a -> FreeT f m b -> FreeT f m c
(Functor f, Monad m) => Bind (FreeT f m) |
Instance details Defined in Control.Monad.Trans.Free Methods (>>-) :: FreeT f m a -> (a -> FreeT f m b) -> FreeT f m b join :: FreeT f m (FreeT f m a) -> FreeT f m a
(Read1 f, Read1 m, Read a) => Read (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods readsPrec :: Int -> ReadS (FreeT f m a) Source # readList :: ReadS [FreeT f m a] Source # readPrec :: ReadPrec (FreeT f m a) Source # readListPrec :: ReadPrec [FreeT f m a] Source #
(Show1 f, Show1 m, Show a) => Show (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods showsPrec :: Int -> FreeT f m a -> ShowS Source # show :: FreeT f m a -> String Source # showList :: [FreeT f m a] -> ShowS Source #
(Eq1 f, Eq1 m, Eq a) => Eq (FreeT f m a) |
Instance details Defined in Control.Monad.Trans.Free Methods (==) :: FreeT f m a -> FreeT f m a -> Bool Source # (/=) :: FreeT f m a -> FreeT f m a -> Bool Source #
(Ord1 f, Ord1 m, Ord a) => Ord (FreeT f m a) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

compare :: FreeT f m a -> FreeT f m a -> Ordering Source #

(<) :: FreeT f m a -> FreeT f m a -> Bool Source #

(<=) :: FreeT f m a -> FreeT f m a -> Bool Source #

(>) :: FreeT f m a -> FreeT f m a -> Bool Source #

(>=) :: FreeT f m a -> FreeT f m a -> Bool Source #

max :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #

min :: FreeT f m a -> FreeT f m a -> FreeT f m a Source #

data FreeF (f :: Type -> Type) a b Source #

The base functor for a free monad.

Constructors

Pure a |
Free (f b) |

#### Instances

Instances details

Generic1 (FreeF f a :: Type -> Type) |
Instance details Defined in Control.Monad.Trans.Free Associated Types type Rep1 (FreeF f a) :: k -> Type Source # Methods from1 :: forall (a0 :: k). FreeF f a a0 -> Rep1 (FreeF f a) a0 Source # to1 :: forall (a0 :: k). Rep1 (FreeF f a) a0 -> FreeF f a a0 Source #
Foldable f => Bifoldable (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods bifold :: Monoid m => FreeF f m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> FreeF f a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> FreeF f a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> FreeF f a b -> c Source #
Functor f => Bifunctor (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods bimap :: (a -> b) -> (c -> d) -> FreeF f a c -> FreeF f b d Source # first :: (a -> b) -> FreeF f a c -> FreeF f b c Source # second :: (b -> c) -> FreeF f a b -> FreeF f a c Source #
Traversable f => Bitraversable (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods bitraverse :: Applicative f0 => (a -> f0 c) -> (b -> f0 d) -> FreeF f a b -> f0 (FreeF f c d) Source #
Eq1 f => Eq2 (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> FreeF f a c -> FreeF f b d -> Bool Source #
Ord1 f => Ord2 (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> FreeF f a c -> FreeF f b d -> Ordering Source #
Read1 f => Read2 (FreeF f) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (FreeF f a b) Source #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [FreeF f a b] Source #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (FreeF f a b) Source #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [FreeF f a b] Source #

Show1 f => Show2 (FreeF f) |
Instance details Defined in Control.Monad.Trans.Free Methods liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> FreeF f a b -> ShowS Source # liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [FreeF f a b] -> ShowS Source #
Foldable f => Foldable (FreeF f a) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

fold :: Monoid m => FreeF f a m -> m Source #

foldMap :: Monoid m => (a0 -> m) -> FreeF f a a0 -> m Source #

foldMap' :: Monoid m => (a0 -> m) -> FreeF f a a0 -> m Source #

foldr :: (a0 -> b -> b) -> b -> FreeF f a a0 -> b Source #

foldr' :: (a0 -> b -> b) -> b -> FreeF f a a0 -> b Source #

foldl :: (b -> a0 -> b) -> b -> FreeF f a a0 -> b Source #

foldl' :: (b -> a0 -> b) -> b -> FreeF f a a0 -> b Source #

foldr1 :: (a0 -> a0 -> a0) -> FreeF f a a0 -> a0 Source #

foldl1 :: (a0 -> a0 -> a0) -> FreeF f a a0 -> a0 Source #

toList :: FreeF f a a0 -> [a0] Source #

null :: FreeF f a a0 -> Bool Source #

length :: FreeF f a a0 -> Int Source #

elem :: Eq a0 => a0 -> FreeF f a a0 -> Bool Source #

maximum :: Ord a0 => FreeF f a a0 -> a0 Source #

minimum :: Ord a0 => FreeF f a a0 -> a0 Source #

sum :: Num a0 => FreeF f a a0 -> a0 Source #

product :: Num a0 => FreeF f a a0 -> a0 Source #

(Eq1 f, Eq a) => Eq1 (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods liftEq :: (a0 -> b -> Bool) -> FreeF f a a0 -> FreeF f a b -> Bool Source #
(Ord1 f, Ord a) => Ord1 (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods liftCompare :: (a0 -> b -> Ordering) -> FreeF f a a0 -> FreeF f a b -> Ordering Source #
(Read1 f, Read a) => Read1 (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (FreeF f a a0) Source # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [FreeF f a a0] Source # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (FreeF f a a0) Source # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [FreeF f a a0] Source #
(Show1 f, Show a) => Show1 (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> FreeF f a a0 -> ShowS Source # liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [FreeF f a a0] -> ShowS Source #
Traversable f => Traversable (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods traverse :: Applicative f0 => (a0 -> f0 b) -> FreeF f a a0 -> f0 (FreeF f a b) Source # sequenceA :: Applicative f0 => FreeF f a (f0 a0) -> f0 (FreeF f a a0) Source # mapM :: Monad m => (a0 -> m b) -> FreeF f a a0 -> m (FreeF f a b) Source # sequence :: Monad m => FreeF f a (m a0) -> m (FreeF f a a0) Source #
Functor f => Functor (FreeF f a) |
Instance details Defined in Control.Monad.Trans.Free Methods fmap :: (a0 -> b) -> FreeF f a a0 -> FreeF f a b Source # (<$) :: a0 -> FreeF f a b -> FreeF f a a0 Source #
(Typeable f, Typeable b, Data a, Data (f b)) => Data (FreeF f a b) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> FreeF f a b -> c (FreeF f a b) Source #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FreeF f a b) Source #

toConstr :: FreeF f a b -> Constr Source #

dataTypeOf :: FreeF f a b -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FreeF f a b)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FreeF f a b)) Source #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> FreeF f a b -> FreeF f a b Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FreeF f a b -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FreeF f a b -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> FreeF f a b -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FreeF f a b -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FreeF f a b -> m (FreeF f a b) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FreeF f a b -> m (FreeF f a b) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FreeF f a b -> m (FreeF f a b) Source #

Generic (FreeF f a b) |
Instance details Defined in Control.Monad.Trans.Free Associated Types type Rep (FreeF f a b) :: Type -> Type Source # Methods from :: FreeF f a b -> Rep (FreeF f a b) x Source # to :: Rep (FreeF f a b) x -> FreeF f a b Source #
(Read a, Read (f b)) => Read (FreeF f a b) |
Instance details Defined in Control.Monad.Trans.Free Methods readsPrec :: Int -> ReadS (FreeF f a b) Source # readList :: ReadS [FreeF f a b] Source # readPrec :: ReadPrec (FreeF f a b) Source # readListPrec :: ReadPrec [FreeF f a b] Source #
(Show a, Show (f b)) => Show (FreeF f a b) |
Instance details Defined in Control.Monad.Trans.Free Methods showsPrec :: Int -> FreeF f a b -> ShowS Source # show :: FreeF f a b -> String Source # showList :: [FreeF f a b] -> ShowS Source #
(Eq a, Eq (f b)) => Eq (FreeF f a b) |
Instance details Defined in Control.Monad.Trans.Free Methods (==) :: FreeF f a b -> FreeF f a b -> Bool Source # (/=) :: FreeF f a b -> FreeF f a b -> Bool Source #
(Ord a, Ord (f b)) => Ord (FreeF f a b) |

Instance details

Defined in Control.Monad.Trans.Free

Methods

compare :: FreeF f a b -> FreeF f a b -> Ordering Source #

(<) :: FreeF f a b -> FreeF f a b -> Bool Source #

(<=) :: FreeF f a b -> FreeF f a b -> Bool Source #

(>) :: FreeF f a b -> FreeF f a b -> Bool Source #

(>=) :: FreeF f a b -> FreeF f a b -> Bool Source #

max :: FreeF f a b -> FreeF f a b -> FreeF f a b Source #

min :: FreeF f a b -> FreeF f a b -> FreeF f a b Source #

type Rep1 (FreeF f a :: Type -> Type) |

Instance details

Defined in Control.Monad.Trans.Free

type Rep1 (FreeF f a :: Type -> Type) = D1 ('MetaData "FreeF" "Control.Monad.Trans.Free" "free-5.2-FL6CaFgGQUvKQsyzLkxXHS" 'False) (C1 ('MetaCons "Pure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Free" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))

type Rep (FreeF f a b) |

Instance details

Defined in Control.Monad.Trans.Free

type Rep (FreeF f a b) = D1 ('MetaData "FreeF" "Control.Monad.Trans.Free" "free-5.2-FL6CaFgGQUvKQsyzLkxXHS" 'False) (C1 ('MetaCons "Pure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Free" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f b))))

type Producer b = Proxy X () () b Source #

`Producer`s can only `yield`

yield :: forall (m :: Type -> Type) a x' x. Functor m => a -> Proxy x' x () a m () Source #

Produce a value

    yield :: Monad m => a -> Producer a m ()
    yield :: Monad m => a -> Pipe   x a m ()

next :: Monad m => Producer a m r -> m (Either r (a, Producer a m r)) Source #

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`.