Copyright | (c) Fumiaki Kinoshita 2015 |
---|---|

License | BSD3 |

Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | Safe |

Language | Haskell2010 |

- data Request a b r = Request a (b -> r)
- mapRequest :: (a -> a') -> Request a b r -> Request a' b r
- request :: a -> Request a b b
- accept :: Functor m => (a -> m b) -> Request a b r -> m r
- mealy :: Functor m => (a -> m (b, Object (Request a b) m)) -> Object (Request a b) m
- flyweight :: (Applicative m, Eq k, Hashable k) => (k -> m a) -> Object (Request k a) m
- (>~~>) :: Monad m => Object (Request a b) m -> Object (Request b c) m -> Object (Request a c) m
- accumulator :: Applicative m => (b -> a -> b) -> b -> Object (Request a b) m
- animate :: (Applicative m, Num t) => (t -> m a) -> Object (Request t a) m
- transit :: (Alternative m, Fractional t, Ord t) => t -> (t -> m a) -> Object (Request t a) m

# Documentation

mapRequest :: (a -> a') -> Request a b r -> Request a' b r Source #

Apply a function to the body of `Request`

accept :: Functor m => (a -> m b) -> Request a b r -> m r Source #

Handle a `Request`

, smashing the continuation.

mealy :: Functor m => (a -> m (b, Object (Request a b) m)) -> Object (Request a b) m Source #

Add a step as a mealy machine

flyweight :: (Applicative m, Eq k, Hashable k) => (k -> m a) -> Object (Request k a) m Source #

The flyweight object

(>~~>) :: Monad m => Object (Request a b) m -> Object (Request b c) m -> Object (Request a c) m Source #

Compose mealy machines

accumulator :: Applicative m => (b -> a -> b) -> b -> Object (Request a b) m Source #

animate :: (Applicative m, Num t) => (t -> m a) -> Object (Request t a) m Source #

Create a mealy machine from a time-varying action.

animate f ≡ accumulator (+) 0 >~~> liftO (accept f)

transit :: (Alternative m, Fractional t, Ord t) => t -> (t -> m a) -> Object (Request t a) m Source #

Like `animate`

, but the life is limited.