Safe Haskell | None |
---|
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.
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'
anda
- The upstream interface, where(a')
s go out and(a)
s come in -
b'
andb
- The downstream interface, where(b)
s go out and(b')
s come in -
m
- The base monad -
r
- The return value
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 |
MonadError e m => MonadError e (Proxy a' a b' b m) | |
MonadReader r m => MonadReader r (Proxy a' a b' b m) | |
MonadState s m => MonadState s (Proxy a' a b' b m) | |
MonadWriter w m => MonadWriter w (Proxy a' a b' b m) | |
MFunctor (Proxy a' a b' b) | |
MonadTrans (Proxy a' a b' b) | |
Monad m => Monad (Proxy a' a b' b m) | |
Monad m => Functor (Proxy a' a b' b m) | |
MonadPlus m => MonadPlus (Proxy a' a b' b m) | |
Monad m => Applicative (Proxy a' a b' b m) | |
MonadPlus m => Alternative (Proxy a' a b' b m) | |
MonadIO m => MonadIO (Proxy a' a b' b m) |
unsafeHoist :: Monad m => (forall x. m x -> n x) -> Proxy a' a b' b m r -> Proxy a' a b' b n rSource
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 rSource
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.