Suggested style to disambiguate function parameters
App Development3 posts203 views6 likesLast activity Sep 2021
LE
Leonid_RozenbergOP
Sep 2021Suppose 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 2021but this does not really help when you start using
..syntax.
“Don’t use .. syntax”?
CO
cocreature
Sep 2021The two options here are:
- Records which you suggested yourself
- newtypes, e.g.,
newtype MaruityDate = MaruityDate { getMaturityDate : Date }
There is no special support for labeled or named arguments in Daml.