One can submit multiple commands inside of Daml Script as documented here, but I always forget the pure ()
at the end and get an error that is not obvious to me.
What’s the technical reason why we need that pure ()
at the end?
One can submit multiple commands inside of Daml Script as documented here, but I always forget the pure ()
at the end and get an error that is not obvious to me.
What’s the technical reason why we need that pure ()
at the end?
The perhaps unsatisfying but accurate reason is because that’s what GHC implemented. There are good reasons for GHC’s restriction here. In general, Applicative is more limited. In the context of Daml Script that means you cannot have dependencies between the commands. GHC has some heuristics to translate do blocks without dependencies to Applicative operations. You could imagine more complex heuristics but on the other hand those would also be more confusing in their failure cases. The current restrictions on the other hand might feel unnecessarily restrictive but they’re fairly easy to follow.