Skip to content
Discussions/App Development/Is the `ApplicativeDo` language pragma implicitly enabled in Daml? Update: no, it isn'tForum ↗

Is the `ApplicativeDo` language pragma implicitly enabled in Daml? Update: no, it isn't

App Development5 posts375 views9 likesLast activity Feb 2021
GY
gyorgybalazsiOP
Feb 2021

The Daml docs says about the Commands data type:

“This is used to build up the commands sent as part of submit. If you enable the ApplicativeDo extension by adding {-# LANGUAGE ApplicativeDo #-} at the top of your file, you can use do-notation but the individual commands must not depend on each other and the last statement in a do block must be of the form return expr or pure expr.”

See Module Daml.Script — Daml SDK 1.10.0 documentation

Is my observation correct that enabling this pragma is not needed any more?

CO
cocreature
Feb 2021

The pragma is still needed but you only need it if you actually make use of do notation. E.g., the following works without the pragma because the do is redundant.

submit p $ do createCmd …

This one does not:

submit p $ do
  c1 <- createCmd …
  c2 <- createCmd
  pure (c1, c2)
GY
gyorgybalazsi
Feb 2021

Thank you!

ST
Stephen
Feb 2021

Further to what @cocreature said, it is only needed for dos associated with Commands. Script (the Action that submit produces in this context) can use do without the pragma.

If you need this pragma and haven’t added it, compilation will fail. Conversely, if you don’t have it and your code is compiling, you don’t need it.

GY
gyorgybalazsi
Feb 2021

Thank you!

← Back to Discussions