Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Why is the `DA.Date` module imported qualified?Forum ↗

Why is the `DA.Date` module imported qualified?

App Development3 posts146 views3 likesLast activity Mar 2022
GY
gyorgybalazsiOP
Mar 2022

I can see in some Daml code that the DA.Date module is imported qualified like this:

import DA.Date qualified as D

after which the functions from the module are used like this:

dateOfBirth = D.date 2021 D.Aug 12

I cannot see the point of this, what am I missing?

CO
cocreature
Mar 2022

There are two main reasons for qualified imports in general:

  1. To avoid collisions between functions with the same name.
  2. Readability: It makes it a lot easier to see where a function was imported from without having to rely on editor tooling or guessing which can be helpful in particular for readers that are not that familiar with a library. This is obviously highly subjective as most readability questions

I don’t know where you got your example from but having two functions called date seems fairly unlikely so it’s probably because of 2.

GE
georg
Mar 2022

I find myself often in the situation that a template field called date conflicts with the import. This is usually the reason I have to qualify it.

← Back to Discussions