Skip to content
Discussions/App Development/What does these syntax means?Forum ↗

What does these syntax means?

App Development3 posts194 views1 likesLast activity Feb 2022
NA
NagatoPeinI1OP
Feb 2022
import DA.Assert ((===))
import DA.Finance.Types (Account, Asset)
import DA.Finance.Asset (AssetDeposit(..), AssetDeposit_Transfer(..), AssetDeposit_SetObservers(..))
import Prelude hiding (lookup)

I was going through the DAML GitHub code for the DAML finance library.
what does ((===)), (..), hiding means?
What is the difference between importing (Account, Asset) vs (AssetDeposit(..), AssetDeposit_Transfer(..), AssetDeposit_SetObservers(..))

ST
stefanobaghino-da
Feb 2022

The following means that you are importing the === function from the DA.Assert module. The extra pair of parentheses is needed for the compiler to correctly parse that.

import DA.Assert ((===))

hiding means that you are “opting out” of an import. Prelude is imported transparently to the user. In this case we are making sure that lookup from the Prelude is hidden. You can still use it by using the fully qualified name, though.


EDIT: the following is from my original answer but as pointed out by @Luciano, it’s incorrect. Thanks for fixing it. :bowing_man:

The (..) syntax allows you to import all functions in a given module. The following means you are importing all the functions from the DA.Finance.Asset.AssetDeposit module and so on.

The difference between importing all the functions directly and importing just DA.Finance.Asset is that in the former case you can refer to the functions directly by name latter case you need to qualify the functions (something), in the latter you will need to qualify the function names (Asset.AssetDeposit.something)

import DA.Finance.Asset (AssetDeposit(..), AssetDeposit_Transfer(..), AssetDeposit_SetObservers(..))
LU
Luciano
Feb 2022
stefanobaghino-da:

The (..) syntax allows you to import all functions in a given module

That’s not quite right. In this case, (..) is used to import the constructors of the type, in addition to the type itself.

Also suggest looking at this post/tutorial :

Tutorials and Guides - Daml Developers Community

← Back to Discussions