-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A simple, yet powerful extensible effects library. -- -- A simple, performant extensible effects library with seamless -- integration with the existing Haskell ecosystem. @package effectful @version 0.0.0.0 -- | Type-safe indexing for Env. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Effectful.Internal.Has type Effect = Type class (e :: Effect) :> (es :: [Effect]) -- | Get position of e in the Env. ixEnv :: forall e es. e :> es => Int -> Int instance e Effectful.Internal.Has.:> (e : es) instance (e Effectful.Internal.Has.:> es) => e Effectful.Internal.Has.:> (x : es) -- | The enviroment for Eff. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Effectful.Internal.Env -- | A mutable, extensible record indexed by effect data types. data Env (es :: [Effect]) -- | Create an empty environment. emptyEnv :: IO (Env '[]) -- | Clone the environment. cloneEnv :: Env es -> IO (Env es) -- | Get the current size of the environment. sizeEnv :: Env es -> IO Int -- | Take last k values from the top of the environment. takeLastEnv :: HasCallStack => Int -> Env es0 -> IO (Env es) -- | Extract a specific data type from the environment. getEnv :: forall e es. (HasCallStack, e :> es) => Env es -> IO e -- | Check that the size of the environment is the same as the expected -- value. checkSizeEnv :: HasCallStack => Int -> Env es -> IO () -- | Replace the first argument with the second one in place. unsafeReplaceEnv :: HasCallStack => Env es -> Env es -> IO () -- | Extend the environment with a new data type in place. unsafeConsEnv :: HasCallStack => e -> Env es -> IO (Env (e : es)) -- | Extend the first environment with the second one in place. unsafeAppendEnv :: HasCallStack => Env es0 -> Env es1 -> IO (Env es) -- | Trim the environment to the given size in place. unsafeTrimEnv :: HasCallStack => Int -> Env es -> IO (Env es0) -- | Replace the data type in the environment with a new value in place. unsafePutEnv :: forall e es. (HasCallStack, e :> es) => e -> Env es -> IO () -- | Modify the data type in the environment in place. unsafeModifyEnv :: forall e es. (HasCallStack, e :> es) => (e -> e) -> Env es -> IO () -- | Modify the data type in the enviroment in place and return a value. unsafeStateEnv :: forall e es a. (HasCallStack, e :> es) => (e -> (a, e)) -> Env es -> IO a -- | The Eff monad. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Effectful.Internal.Monad newtype Eff (es :: [Effect]) a Eff :: (Env es -> IO a) -> Eff (es :: [Effect]) a [unEff] :: Eff (es :: [Effect]) a -> Env es -> IO a runEff :: Eff '[] a -> IO a impureEff :: (Env es -> IO a) -> Eff es a impureEff_ :: IO a -> Eff es a data IOE runIOE :: Eff '[IOE] a -> Eff '[] a runEffect :: e -> Eff (e : es) a -> Eff es (a, e) evalEffect :: e -> Eff (e : es) a -> Eff es a execEffect :: e -> Eff (e : es) a -> Eff es e getEffect :: e :> es => Eff es e putEffect :: e :> es => e -> Eff es () stateEffect :: e :> es => (e -> (a, e)) -> Eff es a localEffect :: e :> es => (e -> e) -> Eff es a -> Eff es a listenEffect :: (e :> es, Monoid e) => Eff es a -> Eff es (a, e) readerEffectM :: e :> es => (e -> Eff es a) -> Eff es a stateEffectM :: e :> es => (e -> Eff es (a, e)) -> Eff es a instance (Effectful.Internal.Monad.IOE Effectful.Internal.Has.:> es) => Control.Monad.IO.Class.MonadIO (Effectful.Internal.Monad.Eff es) instance (Effectful.Internal.Monad.IOE Effectful.Internal.Has.:> es) => Control.Monad.Base.MonadBase GHC.Types.IO (Effectful.Internal.Monad.Eff es) instance (Effectful.Internal.Monad.IOE Effectful.Internal.Has.:> es) => Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO (Effectful.Internal.Monad.Eff es) instance (Effectful.Internal.Monad.IOE Effectful.Internal.Has.:> es) => Control.Monad.IO.Unlift.MonadUnliftIO (Effectful.Internal.Monad.Eff es) instance GHC.Base.Functor (Effectful.Internal.Monad.Eff es) instance GHC.Base.Applicative (Effectful.Internal.Monad.Eff es) instance GHC.Base.Monad (Effectful.Internal.Monad.Eff es) instance Control.Monad.Catch.MonadThrow (Effectful.Internal.Monad.Eff es) instance Control.Monad.Catch.MonadCatch (Effectful.Internal.Monad.Eff es) instance Control.Monad.Catch.MonadMask (Effectful.Internal.Monad.Eff es) -- | Experimental support for coroutines. module Effectful.Coroutine data Coroutine o i data Status es o i r Done :: r -> Status es o i r Yielded :: o -> (i -> Eff es (Status es o i r)) -> Status es o i r runCoroutine :: Eff (Coroutine o i : es) r -> Eff es (Status es o i r) yield :: Coroutine o i :> es => o -> Eff es i module Effectful data Eff (es :: [Effect]) a runEff :: Eff '[] a -> IO a type Effect = Type class (e :: Effect) :> (es :: [Effect]) data IOE runIOE :: Eff '[IOE] a -> Eff '[] a impureEff :: (Env es -> IO a) -> Eff es a impureEff_ :: IO a -> Eff es a runEffect :: e -> Eff (e : es) a -> Eff es (a, e) evalEffect :: e -> Eff (e : es) a -> Eff es a execEffect :: e -> Eff (e : es) a -> Eff es e getEffect :: e :> es => Eff es e putEffect :: e :> es => e -> Eff es () stateEffect :: e :> es => (e -> (a, e)) -> Eff es a localEffect :: e :> es => (e -> e) -> Eff es a -> Eff es a listenEffect :: (e :> es, Monoid e) => Eff es a -> Eff es (a, e) readerEffectM :: e :> es => (e -> Eff es a) -> Eff es a stateEffectM :: e :> es => (e -> Eff es (a, e)) -> Eff es a -- | Miscellaneous functions. -- -- This module is intended for internal use only, and may change without -- warning in subsequent releases. module Effectful.Internal.Utils -- | Pretty print a position from a CallStack. ppCallStack :: (String, SrcLoc) -> String -- | Support for checked exceptions. module Effectful.Error data Error e runError :: forall e es a. Exception e => Eff (Error e : es) a -> Eff es (Either ([String], e) a) throwError :: (HasCallStack, Exception e, Error e :> es) => e -> Eff es a catchError :: (Exception e, Error e :> es) => Eff es a -> ([String] -> e -> Eff es a) -> Eff es a tryError :: (Exception e, Error e :> es) => Eff es a -> Eff es (Either ([String], e) a) instance GHC.Show.Show e => GHC.Show.Show (Effectful.Error.WrapE e) instance (GHC.Show.Show e, Data.Typeable.Internal.Typeable e) => GHC.Exception.Type.Exception (Effectful.Error.WrapE e) -- | The Reader as an effect. module Effectful.Reader -- | Provide access to a read only value of type r. data Reader r runReader :: r -> Eff (Reader r : es) a -> Eff es a ask :: Reader r :> es => Eff es r local :: Reader r :> es => (r -> r) -> Eff es a -> Eff es a reader :: Reader r :> es => (r -> a) -> Eff es a asks :: Reader r :> es => (r -> a) -> Eff es a module Effectful.Class.Reader -- | Compatiblity layer for a transition period from MTL-style effect -- handling to Eff. class Monad m => MonadReader r m ask :: MonadReader r m => m r local :: MonadReader r m => (r -> r) -> m a -> m a reader :: MonadReader r m => (r -> a) -> m a asks :: MonadReader r m => (r -> a) -> m a instance (Effectful.Class.Reader.MonadReader r m, Control.Monad.Trans.Control.MonadTransControl t, GHC.Base.Monad (t m)) => Effectful.Class.Reader.MonadReader r (t m) instance (Effectful.Reader.Reader r Effectful.Internal.Has.:> es) => Effectful.Class.Reader.MonadReader r (Effectful.Internal.Monad.Eff es) -- | Resource management via MonadResource. module Effectful.Resource -- | Data tag for a resource effect. data Resource -- | Run the resource effect. runResource :: Eff (Resource : es) a -> Eff es a -- | Perform some allocation, and automatically register a cleanup action. -- -- This is almost identical to calling the allocation and then -- registering the release action, but this properly handles -- masking of asynchronous exceptions. -- -- Since 0.3.0 allocate :: MonadResource m => IO a -> (a -> IO ()) -> m (ReleaseKey, a) -- | Perform some allocation where the return value is not required, and -- automatically register a cleanup action. -- -- allocate_ is to allocate as bracket_ is to -- bracket -- -- This is almost identical to calling the allocation and then -- registering the release action, but this properly handles -- masking of asynchronous exceptions. allocate_ :: MonadResource m => IO a -> IO () -> m ReleaseKey -- | Register some action that will be called precisely once, either when -- runResourceT is called, or when the ReleaseKey is passed -- to release. -- -- Since 0.3.0 register :: MonadResource m => IO () -> m ReleaseKey -- | Call a release action early, and deregister it from the list of -- cleanup actions to be performed. -- -- Since 0.3.0 release :: MonadIO m => ReleaseKey -> m () -- | Unprotect resource from cleanup actions; this allows you to send -- resource into another resourcet process and reregister it there. It -- returns a release action that should be run in order to clean resource -- or Nothing in case if resource is already freed. -- -- Since 0.4.5 unprotect :: MonadIO m => ReleaseKey -> m (Maybe (IO ())) instance (Effectful.Internal.Monad.IOE Effectful.Internal.Has.:> es, Effectful.Resource.Resource Effectful.Internal.Has.:> es) => Control.Monad.Trans.Resource.Internal.MonadResource (Effectful.Internal.Monad.Eff es) -- | The State as an effect. -- -- Represented as a pure value underneath, therefore: -- -- -- -- If you plan to do the latter, have a look at -- Effective.State.MVar or Effective.State.Dynamic. module Effectful.State -- | Provide access to a pure, mutable state of type s. data State s runState :: s -> Eff (State s : es) a -> Eff es (a, s) evalState :: s -> Eff (State s : es) a -> Eff es a execState :: s -> Eff (State s : es) a -> Eff es s get :: State s :> es => Eff es s put :: State s :> es => s -> Eff es () state :: State s :> es => (s -> (a, s)) -> Eff es a modify :: State s :> es => (s -> s) -> Eff es () stateM :: State s :> es => (s -> Eff es (a, s)) -> Eff es a modifyM :: State s :> es => (s -> Eff es s) -> Eff es () -- | The State as an effect with dynamic dispatch. -- -- It's not clear in which situation it's beneficial to use this instead -- of Effective.State or Effective.State.MVar as you -- either: -- -- -- -- However, let's include this for now. module Effectful.State.Dynamic -- | Provide access to a mutable state of type s. -- -- Whether the state is represented as a pure value or an MVar -- depends on the interpretation. data State s runState :: s -> Eff (State s : es) a -> Eff es (a, s) evalState :: s -> Eff (State s : es) a -> Eff es a execState :: s -> Eff (State s : es) a -> Eff es s runStateMVar :: s -> Eff (State s : es) a -> Eff es (a, s) evalStateMVar :: s -> Eff (State s : es) a -> Eff es a execStateMVar :: s -> Eff (State s : es) a -> Eff es s get :: State s :> es => Eff es s put :: State s :> es => s -> Eff es () state :: State s :> es => (s -> (a, s)) -> Eff es a modify :: State s :> es => (s -> s) -> Eff es () stateM :: State s :> es => (s -> Eff es (a, s)) -> Eff es a modifyM :: State s :> es => (s -> Eff es s) -> Eff es () module Effectful.Class.State -- | Compatiblity layer for a transition period from MTL-style effect -- handling to Eff. class Monad m => MonadState s m get :: MonadState s m => m s put :: MonadState s m => s -> m () state :: MonadState s m => (s -> (a, s)) -> m a modify :: MonadState s m => (s -> s) -> m () instance (Effectful.Class.State.MonadState s m, Control.Monad.Trans.Class.MonadTrans t, GHC.Base.Monad (t m)) => Effectful.Class.State.MonadState s (t m) instance (Effectful.State.Dynamic.State s Effectful.Internal.Has.:> es) => Effectful.Class.State.MonadState s (Effectful.Internal.Monad.Eff es) -- | The State as an effect. -- -- Represented as an MVar underneath, therefore: -- -- module Effectful.State.MVar -- | Provide access to a synchronized, mutable state of type s. data State s runState :: s -> Eff (State s : es) a -> Eff es (a, s) evalState :: s -> Eff (State s : es) a -> Eff es a execState :: s -> Eff (State s : es) a -> Eff es s get :: State s :> es => Eff es s put :: State s :> es => s -> Eff es () state :: State s :> es => (s -> (a, s)) -> Eff es a modify :: State s :> es => (s -> s) -> Eff es () stateM :: State s :> es => (s -> Eff es (a, s)) -> Eff es a modifyM :: State s :> es => (s -> Eff es s) -> Eff es () -- | The Writer as an effect. module Effectful.Writer -- | Provide access to a write only value of type w. data Writer w runWriter :: Monoid w => Eff (Writer w : es) a -> Eff es (a, w) execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w writer :: (Writer w :> es, Monoid w) => (a, w) -> Eff es a tell :: (Writer w :> es, Monoid w) => w -> Eff es () listen :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w) listens :: (Writer w :> es, Monoid w) => (w -> b) -> Eff es a -> Eff es (a, b) instance GHC.Base.Monoid w => GHC.Base.Monoid (Effectful.Writer.Writer w) instance GHC.Base.Semigroup w => GHC.Base.Semigroup (Effectful.Writer.Writer w) module Effectful.Class.Writer -- | Compatiblity layer for a transition period from MTL-style effect -- handling to Eff. class Monad m => MonadWriter w m writer :: MonadWriter w m => (a, w) -> m a tell :: MonadWriter w m => w -> m () listen :: MonadWriter w m => m a -> m (a, w) listens :: MonadWriter w m => (w -> b) -> m a -> m (a, b) instance (Effectful.Class.Writer.MonadWriter w m, Control.Monad.Trans.Control.MonadTransControl t, GHC.Base.Monad (t m)) => Effectful.Class.Writer.MonadWriter w (t m) instance (Effectful.Writer.Writer w Effectful.Internal.Has.:> es, GHC.Base.Monoid w) => Effectful.Class.Writer.MonadWriter w (Effectful.Internal.Monad.Eff es)