objective-1.1.1: Composable objects

Copyright(c) Fumiaki Kinoshita 2015
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Safe HaskellSafe






data Request a b r Source

Request a b is the type of a request that sends a to receive b.


Request a (b -> r) 

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

Apply a function to the body of Request

request :: a -> Request a b b Source

Create a 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.