Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Suggested style to disambiguate function parametersForum ↗

Suggested style to disambiguate function parameters

App Development3 posts203 views6 likesLast activity Sep 2021
LE
Leonid_RozenbergOP
Sep 2021

Suppose that I have a function

expirationDate : Int -> Date -> Date -> Date
expirationDate offset maturityDate creationDate =
  if somePredicate maturityDate then
   ...

What is the recommended way to convey the different Date arguments in this function. Some languages support labeled or named arguments. What’s the best way to do something like this in Daml?

I’ve found myself wanting to create and pass custom records for function;

data ExpirationDateArgs = ExpirationDateArgs with
  offset : Int
  maturityDate : Date
  creationDate : Date

but this does not really help when you start using .. syntax.

GA
Gary_Verhaegen
Sep 2021
Leonid_Rozenberg:

but this does not really help when you start using .. syntax.

“Don’t use .. syntax”?

CO
cocreature
Sep 2021

The two options here are:

  1. Records which you suggested yourself
  2. newtypes, e.g., newtype MaruityDate = MaruityDate { getMaturityDate : Date }

There is no special support for labeled or named arguments in Daml.

← Back to Discussions