Import of Daml Multiple Packages Syntax Discovery

I am almost finished a rewrite of the Daml Scripts Doc for basic scripts, but into a more structured presentation, based on a military instructional format, and I was having issues running the code.

I kept on getting this error message in my fancy Vim + LSP:


I reviewed the Docs, searched the forum and even googled externally until it hit me. In the Import cmd at the code of the contract code import Daml.Script (), I thought that perhaps I should do something similar to Python’s import of multiple modules.

import Daml.Script ()
import allocateParty
import createCmd
import blahBlah

In turn, this produced more errors, so just on spec I thought that maybe the multiple imports should be inside the (), and the answer is clearly, yes.

import Daml.Script (allocateParty createCmd archiveCmd script) <- works, errors
import Daml.Script (allocateParty, createCmd, archiveCmd, script) < works, OK

Update: The interpreter on running a test stated that the inclusion of ‘archiveCMD’ & ‘script’ in Daml.Script is now redundant.

Note: Adding these multiple imports is not enough, they must be separated by ’ , ’ as while the contract worked and tested OK, it was continuing to give me visual warnings about everything following ‘allocateParty’.

However I was unable to find this solution in the documents, after five minutes so am asking is there a specific reference to this, or have I just discovered an unintended, but oddly correct action?

@anthony I tried to make the tag ‘daml.script’ as that reflects the exact Daml code reference which I thought might be handy for future searches, however I am unable to create it. Comments?

1 Like

Not sure we have a good reference for this in the documentation but the Daml import syntax is the same as in Haskell so standard Haskell references should do the trick, e.g., Import - HaskellWiki.

Daml.Script is one of those modules that I would usually recommend to import fully so import Daml.Script without any parentheses which will bring all symbols in scope.


I’ve had a quick look through the official docs, and you’re right, there’s not too much information on multiple imports. For a more comprehensive overview, you may want to check the haskell wiki.

Here are some rules of thumb:

  • As you’ve pointed out correctly, you need to use ‘tuple’ to import multiple identifiers from a module.
  • You can do a blanket import by simply writing Daml.Script (without the ()) - this is the equivalent of python’s import Daml.script *.
  • The specific declaration Daml.Script () only imports typeclass definitions, if I’m not mistaken.
  • Remember that if you’re importing infix operators/symbols, you need to wrap them in brackets. e.g. import DA.Functor ((<&>))

I also wrote a more comprehensive post on how to use imports for efficient namespace management you may want to check out.


Thank you, I will edit the code, run it again
and update the document :+1:t2:

1 Like

So how can I get a list of all the available imports?

I was looking through Daml packages and note there is guidance on importing versions of the same package, but that seems to focus directly on the command line as a string, or hardcoded into daml.yaml.

The suggestion from @anthony re StdLib was helpful but I ran a Ctrl-F search in the SDK using the terms 'import module'and got 3 results.

However if I used the search terms 'import da' or 'import DA', there are 28 results, with more nuanced and helpful support.

More being a relative term :grinning:

1 Like

Tags can’t contain a dot, but with your current tags and the content this topic should definitely be findable (example). Really appreciate the effort to make sure topics are searchable :slight_smile:

1 Like

Our standard library is documented here: The standard library — Daml SDK 1.12.0 documentation