-
Notifications
You must be signed in to change notification settings - Fork 201
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
add Action to high-level trigger updateState #7621
Conversation
I’m not sure this is a good idea. Currently we have a very clear separation:
At least for now, most users don’t worry about With this PR, we are changing things a bit:
I realize that for intermediate DAML programmers this is probably not going to be an issue but I’m a bit worried that we’re going to cause confusion for people looking at triggers for the first time with fairly little benefit. Are you planning to include more effects than just the state update? |
@cocreature See #7620 for the overall reasoning for introducing this now.
That's good, because the impression from several of the items in #7392 is that it is really Consider
It seems that it would be most clear and consistent if the way you accessed them would always be via the Or consider the example that this PR very nearly touches:
Supposition 1: you wish to retrieve and modify the state from both
I considered only having this PR introduce the identity monad, honestly, but put in State as a proof of concept. As described, I believe this is the path to the most natural solution to several issues with the API we intend to tackle, and the set of effects would grow accordingly, just not in this PR. |
As we wish to provide multiple similar capabilities between the |
Alright, having thought about this for a few hours, I think I’m convinced. Maybe we can make the docs a bit clearer to avoid any confusion from users around |
CHANGELOG_BEGIN - [Triggers] The ``updateState`` function now returns a ``TriggerStateA``. This is an action like ``TriggerA``, but doesn't permit emitting commands. Instead of taking the state as an argument and returning a new state, you can manipulate the state with ``get``, ``put``, and ``modify``. Any existing ``updateState`` can be ported by replacing ``s -> expr`` in the lambda expression with ``-> modify $ \s ->``, and then made to look nicer from there as desired. See `issue #7621 <https://github.com/digital-asset/daml/pull/7621>`__. CHANGELOG_END
…gger-updatestate-monad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
We could trivially add an identity monad to the
updateState
signature and then build from there, but we might as well use it for something right away, soActionState
moves to the standard library (soget
,put
can be unified) and the new monad gets one of those to control the high-level trigger state.We also introduce
DA.Action.State.Class
.Fixes #7620.
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.