Safe Haskell | None |
---|---|
Language | Haskell2010 |
A box is something that commits and emits
Synopsis
- data Box m c e = Box {}
- bmap :: Monad m => (a' -> m (Maybe a)) -> (b -> m (Maybe b')) -> Box m a b -> Box m a' b'
- hoistb :: Monad m => (forall a. m a -> n a) -> Box m c e -> Box n c e
- glue :: Monad m => Committer m a -> Emitter m a -> m ()
- glue_ :: Monad m => Committer m a -> Emitter m a -> m ()
- glueb :: Monad m => Box m a a -> m ()
- fuse :: Monad m => (a -> m (Maybe b)) -> Box m b a -> m ()
- dotb :: Monad m => Box m a b -> Box m b c -> m (Box m a c)
- class Divap p where
- class Profunctor p => DecAlt p where
Documentation
A Box is a product of a Committer m and an Emitter. Think of a box with an incoming wire and an outgoing wire. Now notice that the abstraction is reversable: are you looking at two wires from "inside a box"; a blind erlang grunt communicating with the outside world via the two thin wires, or are you looking from "outside the box"; interacting with a black box object. Either way, it's a box. And either way, the committer is contravariant and the emitter covariant so it forms a profunctor.
a Box can also be seen as having an input tape and output tape, thus available for turing and finite-state machine metaphorics.
bmap :: Monad m => (a' -> m (Maybe a)) -> (b -> m (Maybe b')) -> Box m a b -> Box m a' b' Source #
a profunctor dimapMaybe
hoistb :: Monad m => (forall a. m a -> n a) -> Box m c e -> Box n c e Source #
Wrong signature for the MFunctor class
glue :: Monad m => Committer m a -> Emitter m a -> m () Source #
Connect an emitter directly to a committer of the same type.
The monadic action returns when the committer finishes.
glue_ :: Monad m => Committer m a -> Emitter m a -> m () Source #
Connect an emitter directly to a committer of the same type.
The monadic action returns if the committer returns False.
fuse :: Monad m => (a -> m (Maybe b)) -> Box m b a -> m () Source #
fuse a box
fuse (pure . pure) == glueb