@@ -40,8 +40,8 @@ import Effectful.Internal.Effect
41type role Env nominal
41type role Env nominal
43−-- | A thread local, mutable, strict (elements are kept in weak head normal
44−-- form), extensible record indexed by data types of kind 'Effect'.
43+-- | A strict (WHNF), thread local, mutable, extensible record indexed by types
46-- Supports forking, i.e. introduction of local branches for encapsulation of
46-- Supports forking, i.e. introduction of local branches for encapsulation of
47-- data specific to effect interpreters.
47-- data specific to effect interpreters.
@@ -56,6 +56,58 @@ type role Env nominal
57-- - Modification of a specific element: /O(1)/.
57-- - Modification of a specific element: /O(1)/.
59+-- Here's an example of how the environment might look:
62+-- e00 - e01 - e05 - e07 (*)
71+-- The point of execution is currently at (*), i.e. the mainline. Moreover,
74+-- - Mainline sees @[e00, e01, e05, e07]@.
76+-- - @e01@ is an interpreted effect, its handler sees @[e00, e02, e03]@.
78+-- - @e03@ is an interpreted effect, its handler sees @[e00, e02, e04]@.
80+-- - @e05@ is an interpreted effect, its handler sees @[e00, e01, e06]@.
82+-- - @e07@ is an interpreted effect, its handler sees @[e00, e01, e05, e08,
85+-- If an operation from @e01@ is invoked, the environment in the middle of
86+-- handling it might look like this:
89+-- e00 - e01 - e05 - e07
93+-- e02 - e03 - e10 (*)
100+-- The point of execution is at (*), i.e. inside the handler of @e01@. The
101+-- handler needed to introduce @e10@ (which introduced @e11@, which in turn
102+-- introduced @e12@), so its local environment was temporarily extended with
103+-- it. Moreover, currently:
105+-- - Handler of @e01@ sees @[e00, e02, e03, e10]@.
107+-- - Handler of @e10@ sees @[e00, e02, e03, e11]@.
109+-- - Handler of @e11@ sees @[e00, e02, e03, e12]@.
59data Env (es :: [Effect]) = Env
111data Env (es :: [Effect]) = Env
60 { _forks :: Forks
112 { _forks :: Forks
61 , _globalRef :: IORef EnvRef
113 , _globalRef :: IORef EnvRef