Skip to content
CCPEDIAby Unity Nodes
App Development

Reexporting modules across DARs

4 posts437 views5 likesLast activity Apr 2021

  1. Tamas_KalczaOP 2

    I wanted to a convenience module where I export some other modules. For example assume I have something like this:

    module Examples.Example (
        answer
      , Fruit (..)
    ) where
    
    answer : Int
    answer = 42
    
    data Fruit = Apple | Banana | Cherry
    

    Then I create the convenience module:

    module Examples.All (
      module Examples.Example
    ) where
    
    import Examples.Example
    

    This works in the project where I define these modules. Meaning if I do import Examples.All the things defined in Example are available.

    This does not seem to work across DARs though. So assume I added the examples.dar as a data-dependency to the examples-test project. Now, even I have the import for the convenience module the things defined in Example are not available.

    Is this by design? Did I do something wrong or missed something?

  2. Gary_Verhaegen 1

    I’m not sure about the “by design” part, but it’s definitely known behaviour/limitation for data-dependencies: these are dependencies on Daml-LF files, rather than Daml source files, and Daml-LF does not have a notion of module declaration: a Daml-LF module is just a bunch of code. No hiding, no reexport.

  3. Luciano 1

    So out of curiosity does this work with the other type of dependency? What is it, just depdendencies: in the daml.yaml file, instead of data-dependencies:?

  4. cocreature 1
    Luciano:

    So out of curiosity does this work with the other type of dependency? What is it, just depdendencies: in the daml.yaml file, instead of data-dependencies: ?

    It works with dependencies but not data-dependencies. I’d still recommend against relying on it since it can lead to confusion since over the JSON and Ledger API you’ll be working with the non-reexported module names.