-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Computational Effects -- -- An alternative to Monad Transformers. @package effects @version 0.1 module Control.Effects -- | with takes a handler and creates a new Proxy (effect -- identifier). The Proxy is passed on to a function which can -- use it to do operations with it. with :: Monad m => Handler e r m a -> (Proxy (ContT e m) -> ContT e m a) -> m r -- | Unwrap the result of the top-level effect. run :: Identity a -> a -- | A Handler e r m a is a handler of effects with type -- e. The ret field provides a function to lift pure -- values into the effect. The fin field provides a function to -- extract a final value of type r from the effect. The -- parameter m should narmally be left polymorphic, it's the -- monad that handles the other effects. data Handler e r m a Handler :: (a -> m e) -> (e -> m r) -> Handler e r m a ret :: Handler e r m a -> a -> m e fin :: Handler e r m a -> e -> m r -- | Define an operation, which is autolifted so it can be used inside -- other effects. operation :: (c ~ (ContT e m), AutoLift c n) => Proxy c -> ((a -> m e) -> m e) -> n a -- | Variant of run that allows I/O effects. (Just the identity -- function, but it helps the type checker.) runIO :: IO () -> IO () -- | Convert an IO action to an I/O effect operation. io :: AutoLift IO n => IO a -> n a -- | The continuation monad transformer. Can be used to add continuation -- handling to other monads. data ContT r m :: (* -> *) a :: * -> (* -> *) -> * -> * data Proxy m :: (* -> *) class AutoLift m1 m2 instance AutoLift' m1 m2 m1 m2 => AutoLift m1 m2 instance AutoLift' m1 m2 n1 n2 => AutoLift' m1 m2 (ContT r1 n1) (ContT r2 n2) instance (AutoLift' m1 m2 Identity n, Monad m2) => AutoLift' m1 (ContT r m2) Identity (ContT s n) instance (AutoLift' m1 m2 IO n, Monad m2) => AutoLift' m1 (ContT r m2) IO (ContT s n) instance m1 ~ m2 => AutoLift' m1 m2 Identity Identity instance m1 ~ m2 => AutoLift' m1 m2 IO IO module Control.Effects.Cont shift :: (c ~ (ContT r m), AutoLift c n, Monad m) => Proxy c -> ((m a -> m r) -> m r) -> n a reset :: Monad m => Handler a a m a module Control.Effects.Either throwEither :: (c ~ (ContT (Either e r) m), AutoLift c n, Monad m) => Proxy c -> e -> n Void catchEither :: Monad m => (e -> m a) -> Handler (Either e a) a m a module Control.Effects.Error throwError :: (c ~ (ContT ((e -> m r) -> m r) m), AutoLift c n, Monad m) => Proxy c -> e -> n Void catchError :: Monad m => (e -> m a) -> Handler ((e -> m a) -> m a) a m a module Control.Effects.Set choose :: (c ~ (ContT (Set r) m), AutoLift c n, Monad m, Ord r) => Proxy c -> [a] -> n a set :: (Monad m, Ord a) => Handler (Set a) (Set a) m a module Control.Effects.State get :: (c ~ (ContT (s -> m r) m), AutoLift c n, Monad m) => Proxy c -> n s put :: (c ~ (ContT (s -> m r) m), AutoLift c n, Monad m) => Proxy c -> s -> n () ref :: Monad m => s -> Handler (s -> m a) a m a module Control.Effects.Writer tell :: (c ~ (ContT (w, r) m), AutoLift c n, Monad m, Monoid w) => Proxy c -> w -> n () writer :: (Monad m, Monoid w) => Handler (w, a) (w, a) m a