effectful-0.0.0.0: A simple, yet powerful extensible effects library.
Safe HaskellNone
LanguageHaskell2010

Effectful.Internal.Env

Description

The enviroment for Eff.

This module is intended for internal use only, and may change without warning in subsequent releases.

Synopsis

Documentation

data Env (es :: [Effect]) Source #

A mutable, extensible record indexed by effect data types.

Safe operations

emptyEnv :: IO (Env '[]) Source #

Create an empty environment.

cloneEnv :: Env es -> IO (Env es) Source #

Clone the environment.

sizeEnv :: Env es -> IO Int Source #

Get the current size of the environment.

takeLastEnv :: HasCallStack => Int -> Env es0 -> IO (Env es) Source #

Take last k values from the top of the environment.

getEnv :: forall e es. (HasCallStack, e :> es) => Env es -> IO e Source #

Extract a specific data type from the environment.

checkSizeEnv :: HasCallStack => Int -> Env es -> IO () Source #

Check that the size of the environment is the same as the expected value.

Extending and shrinking

unsafeReplaceEnv :: HasCallStack => Env es -> Env es -> IO () Source #

Replace the first argument with the second one in place.

unsafeConsEnv :: HasCallStack => e -> Env es -> IO (Env (e ': es)) Source #

Extend the environment with a new data type in place.

unsafeAppendEnv :: HasCallStack => Env es0 -> Env es1 -> IO (Env es) Source #

Extend the first environment with the second one in place.

unsafeTrimEnv :: HasCallStack => Int -> Env es -> IO (Env es0) Source #

Trim the environment to the given size in place.

Data retrieval and update

unsafePutEnv :: forall e es. (HasCallStack, e :> es) => e -> Env es -> IO () Source #

Replace the data type in the environment with a new value in place.

unsafeModifyEnv :: forall e es. (HasCallStack, e :> es) => (e -> e) -> Env es -> IO () Source #

Modify the data type in the environment in place.

unsafeStateEnv :: forall e es a. (HasCallStack, e :> es) => (e -> (a, e)) -> Env es -> IO a Source #

Modify the data type in the enviroment in place and return a value.