Reference: DAML file structure¶
This page gives reference information on the structure of DAML files outside of templates:
Language version (
This file’s module name (
module NameOfThisFile where).
Part of a hierarchical module system to facilitate code reuse. Must be the same as the DAML file name, without the file extension.
For a file with path
module Scenarios.Demo where.
- You can import other modules (
import OtherModuleName), including qualified imports (
import qualified AndYetOtherModuleName,
import qualified AndYetOtherModuleName as Signifier). Can’t have circular import references.
- To import the
- To import a module of
- If you leave out
qualified, and a module alias is specified, top-level declarations of the imported module are imported into the module’s namespace as well as the namespace specified by the given alias.
A DAML library is a collection of related DAML modules.
Define a DAML library using a
LibraryModules.daml file: a normal DAML file that imports the root modules of the library. The library consists of the
LibraryModules.daml file and all its dependencies, found by recursively following the imports of each module.
Bear in mind that the
LibraryModules.daml files are discovered by a bottom up search from the directories of each of the open DAML files. The search uses the first instance of
LibraryModules.daml it finds.
Errors are reported in DAML Studio on a per-library basis. This means that breaking changes on shared DAML modules are displayed even when the files are not explicitly open.
When an instance of a template (that is, a contract) is added to the ledger, it’s assigned a unique identifier, of type
ContractId <name of template>.
The runtime representation of these identifiers depends on the execution environment: a contract identifier from the Sandbox looks different to one on the DA Platform.
You can use
/= on contract identifiers of the same type.