Skip to content

Commit

Permalink
Update docs for runTH and bindTH
Browse files Browse the repository at this point in the history
  • Loading branch information
googleson78 committed Nov 18, 2020
1 parent 478c86e commit 0ff181e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Polysemy/Internal/Tactics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,27 @@ import Polysemy.Internal.Union
-- data 'Polysemy.Resource.Resource' m a where
-- 'Polysemy.Resource.Bracket' :: m a -> (a -> m ()) -> (a -> m b) -> 'Polysemy.Resource.Resource' m b
-- @
-- We can interpret this effect like so:
-- @
-- 'Polysemy.Resource.Bracket' alloc dealloc use -> do
-- a <- 'runTH' alloc
-- res <- 'bindTH' use a
-- 'bindTH' dealloc a
-- pure res
-- @
-- To run the embedded higher-order actions we use 'runTH' for actions
-- (e.g. @m a@) and 'bindTH' for kleisli actions (e.g. @a -> m b@).
-- These functions will run the higher-order actions with
-- \"the current interpreters\" (TODO good explanation on what this means???)
--
-- If you want more control over how other potentially embedded
-- 'Polysemy.Resource.Resource's are run inside your interpeter,
-- you might want to take a look at 'pureT', 'runT' and 'bindT'.
-- An example of when you might need them, is when you are interpreting
-- 'Polysemy.Reader.Local', in which you want to run inner actions
-- with a modified environment.
--
-- TODO modify the section below here?? maybe add the Reader example?
-- Here we have an @m a@ which clearly needs to be run first, and then
-- subsequently call the @a -> m ()@ and @a -> m b@ arguments. In a 'Tactical'
-- environment, we can write the threading code thusly:
Expand Down

0 comments on commit 0ff181e

Please sign in to comment.