@@ -8,7 +8,7 @@ module Strands.Context
88 , initContext
99 , saveContext
1010 , restoreContext
11− , resumeContext
11+ , composeContext
1212 , setContextMailBox
1313 , takeContextMailBox
1414 , getCtxResultDest
@@ -151,7 +151,10 @@ setLocation :: Monad m => Location -> StateT Context m ()
151151setLocation loc = Lazy.modify $ \Context { .. } -> Context { location = loc, .. }
152152
153153------------------------------------------------------------------------------
154−-- Saving and restoring the context of a computation
154+-- Saving and restoring the context of a computation. We perform the monadic
155+-- computation one step at a time storing the context of where we are in the
156+-- computation. At any point the remaining computation can be fully recovered
157+-- from this context.
155158------------------------------------------------------------------------------
156159
157160-- Save the 'm' and 'f', in case we migrate to a new thread before the current
@@ -179,13 +182,14 @@ restoreContext x = do
179182
180183 return mres
181184
182−-- | Resume execution of the computation from a given context. We can retrieve
183−-- a context at any point and resume that context at some later point, upon
184−-- resumption we start executing again from the same point where the context
185−-- was retrieved.
185+-- | We can retrieve a context at any point and resume that context at some
186+-- later point, upon resumption we start executing again from the same point
187+-- where the context was retrieved from.
186188--
187−resumeContext :: (MonadIO m, MonadPlus m) => Context -> m a
188−resumeContext Context { currentm = m
189+-- This function composes the stored context to recover the computation.
190+--
191+composeContext :: (MonadIO m, MonadPlus m) => Context -> m a
192+composeContext Context { currentm = m
189193 , fstack = fs
190194 } =
191195 unsafeCoerce m >>= composefStack (unsafeCoerce fs)