Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
- newtype Object f g = Object {}
- (@-) :: Object f g -> f x -> g (x, Object f g)
- class HProfunctor k where
- echo :: Functor f => Object f f
- liftO :: Functor g => (forall x. f x -> g x) -> Object f g
- (@>>@) :: Functor h => Object f g -> Object g h -> Object f h
- (@<<@) :: Functor h => Object g h -> Object f g -> Object f h
- unfoldO :: Functor g => (forall a. r -> f a -> g (a, r)) -> r -> Object f g
- unfoldOM :: Monad m => (forall a. r -> f a -> m (a, r)) -> r -> Object f m
- stateful :: Monad m => (forall a. t a -> StateT s m a) -> s -> Object t m
- (@~) :: Monad m => s -> (forall a. t a -> StateT s m a) -> Object t m
- iterObject :: Monad m => Object f m -> Free f a -> m (a, Object f m)
- iterative :: Monad m => Object f m -> Object (Free f) m
- variable :: Monad m => s -> Object (StateT s m) m
- announce :: (Traversable t, Monad m) => f a -> StateT (t (Object f m)) m [a]
Documentation
The type Object f g
represents objects which can handle messages f
, perform actions in the environment g
.
It can be thought of as an automaton that converts effects.
Object
s can be composed just like functions using @>>@
; the identity element is echo
.
Objects are morphisms of the category of actions.
- Naturality
runObject obj . fmap f ≡ fmap f . runObject obj
HProfunctor Object | |
Typeable ((* -> *) -> (* -> *) -> *) Object |
class HProfunctor k where Source
liftO :: Functor g => (forall x. f x -> g x) -> Object f g Source
Lift natural transformation into an object
unfoldO :: Functor g => (forall a. r -> f a -> g (a, r)) -> r -> Object f g Source
The unwrapped analog of stateful
unfoldO runObject = id
unfoldO iterObject = iterable
stateful :: Monad m => (forall a. t a -> StateT s m a) -> s -> Object t m Source
Build a stateful object.
stateful t s = t ^>>
variable s@