Why is the `DA.Date` module imported qualified?
- gyorgybalazsiOP
I can see in some Daml code that the
DA.Datemodule is imported qualified like this:import DA.Date qualified as Dafter which the functions from the module are used like this:
dateOfBirth = D.date 2021 D.Aug 12I cannot see the point of this, what am I missing?
- cocreature 1
There are two main reasons for qualified imports in general:
- To avoid collisions between functions with the same name.
- 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
dateseems fairly unlikely so it’s probably because of 2. - georg 2
I find myself often in the situation that a template field called
dateconflicts with the import. This is usually the reason I have to qualify it.