Reexporting modules across DARs
- 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 | CherryThen I create the convenience module:
module Examples.All ( module Examples.Example ) where import Examples.ExampleThis works in the project where I define these modules. Meaning if I do
import Examples.Allthe things defined inExampleare available.This does not seem to work across DARs though. So assume I added the
examples.daras a data-dependency to theexamples-testproject. Now, even I have the import for the convenience module the things defined inExampleare not available.Is this by design? Did I do something wrong or missed something?
- 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. - Luciano 1
So out of curiosity does this work with the other type of dependency? What is it, just
depdendencies:in thedaml.yamlfile, instead ofdata-dependencies:? - cocreature 1
Luciano:So out of curiosity does this work with the other type of dependency? What is it, just
depdendencies:in thedaml.yamlfile, instead ofdata-dependencies:?It works with
dependenciesbut notdata-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.