Suggested style to disambiguate function parameters

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.

1 Like

“Don’t use .. syntax”?

4 Likes

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.

1 Like