Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for runTH and bindTH #394

Closed
wants to merge 2 commits into from

Conversation

googleson78
Copy link
Member

No description provided.

Base automatically changed from interpreth-combinators to master November 18, 2020 19:51
@googleson78 googleson78 marked this pull request as draft November 18, 2020 21:36
@googleson78 googleson78 force-pushed the interpreth-combinators-docs branch 2 times, most recently from 0ff181e to b17f661 Compare November 18, 2020 22:20
@googleson78 googleson78 marked this pull request as ready for review November 18, 2020 22:20
-- @
--
-- The @f@ type here is existential and corresponds to "whatever
Copy link
Member Author

@googleson78 googleson78 Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there is no long an example to attach this talking point to, and it seems rather important, as it explains the that a forall f. Functor f => f ... is being used as "state".

Is there some other example that can be given here to demonstrate this? @KingoftheHomeless @tek @TheMatten

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just put it at the end of the doc comment, so that the association with the type decl is apparent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok obviously that should be "top of the comment" 😄
in any case, the first sentence mentions "threading the state", so it might be sensible to just expand on that there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it back near the top + another piece of documentation that I previously deleted

@googleson78 googleson78 force-pushed the interpreth-combinators-docs branch 4 times, most recently from 37e4aa9 to f65eb9c Compare November 18, 2020 22:30
@googleson78
Copy link
Member Author

Here's a screen of the rendered thing
2020-11-19-003102_1459x888_scrot

We now have runTSimple and bindTSimple and should recommend them to
users.
@googleson78 googleson78 force-pushed the interpreth-combinators-docs branch from f65eb9c to b5d6ee6 Compare November 21, 2020 15:03
@@ -28,8 +28,15 @@ import Polysemy.Internal.Union
-- effect @Tactics@, which is capable of rewriting monadic actions so they run
-- in the correct stateful environment.
--
-- Inside a 'Tactical', you're capable of running 'pureT', 'runT' and 'bindT'
-- which are the main tools for rewriting monadic stateful environments.
-- The @f@ type here is existential and corresponds to "whatever
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the "existential" comment back here.

-- The @f@ type here is existential and corresponds to "whatever
-- state the other effects want to keep track of." @f@ is always
-- a 'Functor'.
-- Note that because of the types of @'bindTSimple' use resource@ and @'bindTSimple' dealloc resource@
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also add this "same environment" comment back here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haddock rendering doesn't do a great job of distinguishing @@ blocks from normal text..

-- 'Polysemy.Resource.Bracket' alloc dealloc use -> do
-- resource <- 'runTSimple' alloc
-- result <- 'bindTSimple' use resource
-- 'bindTSimple' dealloc resource
Copy link
Collaborator

@KingoftheHomeless KingoftheHomeless Nov 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, since this will have dealloc inherit the state from alloc and not result.
The "proper" solution would be:

  fresource <- runTSimple alloc
  fresourceresult <- bindTSimple (\a -> ((,) a) <$> use a) fresource
  bindTSimple (\(resource, result) ->  result <$ dealloc resource) fresourceresult

This is very complicated. Also, this documentation is misleading since this isn't actually how runResource is implemented; it does some extra stuff like using the inspector to check if use failed.

All in all, we should pick a different example than Resource.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, does the current example do the same thing regarding the "state inheritance"? This is the impression I was left with (and it also seems to be the point of the example), from the current documentation.

I guess it would be misleading if the actual runResource runs in a different way.

Copy link
Collaborator

@KingoftheHomeless KingoftheHomeless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, but we need something better than the runResource example. Not sure what we could pick.

@isovector
Copy link
Member

Subsumed by #422 (since all of these functions are going bye-bye.) Closing, but feel free to open if you feel like it!

@isovector isovector closed this Oct 19, 2021
@tek tek deleted the interpreth-combinators-docs branch September 23, 2023 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants