pipes-4.3.16: Compositional pipelines

Safe Haskell | Trustworthy
Language | Haskell2010

Pipes.Internal

Contents

- Internal

Description

This is an internal module, meaning that it is unsafe to import unless you understand the risks.

This module provides a fast implementation by weakening the monad transformer laws. These laws do not hold if you can pattern match on the constructors, as the following counter-example illustrates:

    lift . return = M . return . Pure

    return = Pure

    lift . return /= return

You do not need to worry about this if you do not import this module, since the other modules in this library do not export the constructors or export any functions which can violate the monad transformer laws.

Synopsis

- data Proxy a' a b' b m r
  - = Request a' (a -> Proxy a' a b' b m r)
  - | Respond b (b' -> Proxy a' a b' b m r)
  - | M (m (Proxy a' a b' b m r))
  - | Pure r
- unsafeHoist :: Functor m => (forall x. m x -> n x) -> Proxy a' a b' b m r -> Proxy a' a b' b n r
- observe :: Monad m => Proxy a' a b' b m r -> Proxy a' a b' b m r
- type X = Void
- closed :: X -> a

# Internal

data Proxy a' a b' b m r Source #

A `Proxy` is a monad transformer that receives and sends information on both an upstream and downstream interface.

The type variables signify:

- `a'` and `a` - The upstream interface, where `(a')`s go out and `(a)`s come in
- `b'` and `b` - The downstream interface, where `(b)`s go out and `(b')`s come in
- `m` - The base monad
- `r` - The return value

Constructors

Request a' (a -> Proxy a' a b' b m r) |
Respond b (b' -> Proxy a' a b' b m r) |
M (m (Proxy a' a b' b m r)) |
Pure r |

#### Instances

Instances details

MFunctor (Proxy a' a b' b :: (Type -> Type) -> Type -> Type) Source # |
Instance details Defined in Pipes.Internal Methods hoist :: forall m n (b0 :: k). Monad m => (forall a0. m a0 -> n a0) -> Proxy a' a b' b m b0 -> Proxy a' a b' b n b0 Source #
MonadError e m => MonadError e (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods throwError :: e -> Proxy a' a b' b m a0 Source # catchError :: Proxy a' a b' b m a0 -> (e -> Proxy a' a b' b m a0) -> Proxy a' a b' b m a0 Source #
MonadReader r m => MonadReader r (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods ask :: Proxy a' a b' b m r Source # local :: (r -> r) -> Proxy a' a b' b m a0 -> Proxy a' a b' b m a0 Source # reader :: (r -> a0) -> Proxy a' a b' b m a0 Source #
MonadState s m => MonadState s (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods get :: Proxy a' a b' b m s Source # put :: s -> Proxy a' a b' b m () Source # state :: (s -> (a0, s)) -> Proxy a' a b' b m a0 Source #
MonadWriter w m => MonadWriter w (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods writer :: (a0, w) -> Proxy a' a b' b m a0 Source # tell :: w -> Proxy a' a b' b m () Source # listen :: Proxy a' a b' b m a0 -> Proxy a' a b' b m (a0, w) Source # pass :: Proxy a' a b' b m (a0, w -> w) -> Proxy a' a b' b m a0 Source #
MMonad (Proxy a' a b' b) Source # |
Instance details Defined in Pipes.Internal Methods embed :: forall (n :: Type -> Type) m b0. Monad n => (forall a0. m a0 -> Proxy a' a b' b n a0) -> Proxy a' a b' b m b0 -> Proxy a' a b' b n b0 Source #
MonadTrans (Proxy a' a b' b) Source # |
Instance details Defined in Pipes.Internal Methods lift :: Monad m => m a0 -> Proxy a' a b' b m a0 Source #
MonadFail m => MonadFail (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods fail :: String -> Proxy a' a b' b m a0 Source #
MonadIO m => MonadIO (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods liftIO :: IO a0 -> Proxy a' a b' b m a0 Source #
Functor m => Applicative (Proxy a' a b' b m) Source # |

Instance details

Defined in Pipes.Internal

Methods

pure :: a0 -> Proxy a' a b' b m a0 Source #

(<*>) :: Proxy a' a b' b m (a0 -> b0) -> Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 Source #

liftA2 :: (a0 -> b0 -> c) -> Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 -> Proxy a' a b' b m c Source #

(*>) :: Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 -> Proxy a' a b' b m b0 Source #

(<*) :: Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 -> Proxy a' a b' b m a0 Source #

Functor m => Functor (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods fmap :: (a0 -> b0) -> Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 Source # (<$) :: a0 -> Proxy a' a b' b m b0 -> Proxy a' a b' b m a0 Source #
Functor m => Monad (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods (>>=) :: Proxy a' a b' b m a0 -> (a0 -> Proxy a' a b' b m b0) -> Proxy a' a b' b m b0 Source # (>>) :: Proxy a' a b' b m a0 -> Proxy a' a b' b m b0 -> Proxy a' a b' b m b0 Source # return :: a0 -> Proxy a' a b' b m a0 Source #
MonadCatch m => MonadCatch (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods catch :: Exception e => Proxy a' a b' b m a0 -> (e -> Proxy a' a b' b m a0) -> Proxy a' a b' b m a0 Source #
MonadThrow m => MonadThrow (Proxy a' a b' b m) Source # |
Instance details Defined in Pipes.Internal Methods throwM :: Exception e => e -> Proxy a' a b' b m a0 Source #
(Functor m, Monoid r, Semigroup r) => Monoid (Proxy a' a b' b m r) Source # |
Instance details Defined in Pipes.Internal Methods mempty :: Proxy a' a b' b m r Source # mappend :: Proxy a' a b' b m r -> Proxy a' a b' b m r -> Proxy a' a b' b m r Source # mconcat :: [Proxy a' a b' b m r] -> Proxy a' a b' b m r Source #
(Functor m, Semigroup r) => Semigroup (Proxy a' a b' b m r) Source # |
Instance details Defined in Pipes.Internal Methods (<>) :: Proxy a' a b' b m r -> Proxy a' a b' b m r -> Proxy a' a b' b m r Source # sconcat :: NonEmpty (Proxy a' a b' b m r) -> Proxy a' a b' b m r Source # stimes :: Integral b0 => b0 -> Proxy a' a b' b m r -> Proxy a' a b' b m r Source #

unsafeHoist :: Functor m => (forall x. m x -> n x) -> Proxy a' a b' b m r -> Proxy a' a b' b n r Source #

`unsafeHoist` is like `hoist`, but faster.

This is labeled as unsafe because you will break the monad transformer laws if you do not pass a monad morphism as the first argument. This function is safe if you pass a monad morphism as the first argument.

observe :: Monad m => Proxy a' a b' b m r -> Proxy a' a b' b m r Source #

The monad transformer laws are correct when viewed through the `observe` function:

    observe (lift (return r)) = observe (return r)

    observe (lift (m >>= f)) = observe (lift m >>= lift . f)

This correctness comes at a small cost to performance, so use this function sparingly.

This function is a convenience for low-level `pipes` implementers. You do not need to use `observe` if you stick to the safe API.

type X = Void Source #

The empty type, used to close output ends

closed :: X -> a Source #

Use `closed` to "handle" impossible outputs