1

I come across some examples in the Daml documentation where the operator '$' is being used, but cannot fully understand its purpose.

Example:

submit alice $ create User with username = alice, following = []

Is it the same as do, like in:

submit alice do
  create User with username = alice, following = []

?

rjmAmaro
  • 618
  • 8
  • 20
  • 2
    This answer applies to Daml as well as Haskell :) https://stackoverflow.com/a/1290727/3314107 Hope it helps, happy Daml'ing! – stefanobaghino Feb 15 '21 at 17:54

1 Answers1

2

The $ operator is a substitute for parenthesis. The example

submit alice $ create User with username = alice, following = []

is the same as

submit alice (create User with username = alice, following = [])

To complete, the do is used to declare a code block (more than one line of code):

test = scenario do
  alice <- getParty "Alice"
  bob <- getParty "Bob"
  ...

However, it can also be used in a single line of code:

submit alice do create User with username = alice, following = []
rjmAmaro
  • 618
  • 8
  • 20