Why is ApplicativeDo not doing it's magic?
App Development3 posts230 views3 likesLast activity Dec 2021
BE
bernhardOP
Dec 2021I’ve got {-# LANGUAGE ApplicativeDo #-} at the top of my file. In a script i have
submit issuer do
exerciseCmd eqA_Alice Airdrop with
quantity = 1000.0
reference = None
exerciseCmd eqB_Alice Airdrop with
quantity = 1000.0
reference = None
The first exerciseCmd is underlined with error
• No instance for (Action Commands) arising from a do statement
• In a stmt of a 'do' block:
exerciseCmd eqA_Alice Airdrop {quantity = 1000.0, reference = None}
In the second argument of ‘submit’, namely
‘do exerciseCmd
eqA_Alice Airdrop {quantity = 1000.0, reference = None}
exerciseCmd
eqB_Alice Airdrop {quantity = 1000.0, reference = None}’
In a stmt of a 'do' block:
_ <- submit
issuer
do exerciseCmd
eqA_Alice Airdrop {quantity = 1000.0, reference = None}
exerciseCmd eqB_Alice Airdrop {quantity = 1000.0, reference = None}typecheck
What am I doing wrong?
CO
cocreature
Dec 2021ApplicativeDo is a bit picky because it does syntactic matching on the expression before typechecking. It really wants the last line to be either pure or return. This is documented in Module Daml.Script — Daml SDK 1.18.0 documentation
So if you change your example to the following it should work.
submit issuer do
exerciseCmd …
c <- exerciseCmd …
pure c
BE
bernhard
Dec 2021Of course, I had forgotten that, thanks. I was even on that page and didn’t read the paragraph to the end 