If a third project imports both of the dar
s you generate
dependencies
- daml-finance-interface-0.0.1.dar
- daml-finance-implementation-0.0.1.dar
and then from a new module you try to import one of the modules defined in both of these, you will get an error
Ambiguous module name ‘Daml.Finance.Types’:
it was found in multiple packages:
daml-finance-interface-1.0.0 daml-finance-implementation-1.0.0
You can get around that one with package-qualified imports,
import qualified "daml-finance-interface" Daml.Finance.Types as Interface.Types
import qualified "daml-finance-implementation" Daml.Finance.Types as Implementation.Types
but then the types themselves wouldn’t match
foos = [Interface.Types.Foo, Implementation.Types.Foo]
• Couldn't match expected type ‘Implementation.Types.Foo’
with actual type ‘Interface.Types.Foo’
NB: ‘Interface.Types.Foo’
is defined in ‘Daml.Finance.Types’ in package ‘daml-finance-interface-1.0.0’
‘Implementation.Types.Foo’
is defined in ‘Daml.Finance.Types’ in package ‘daml-finance-implementation-1.0.0’
• In the expression: Interface.Types.Foo
In the expression: [Implementation.Types.Foo, Interface.Types.Foo]
In an equation for ‘foos’: foos = [Implementation.Types.Foo, Interface.Types.Foo]
So, my suggestion would be to split off the shared parts into a separate package that can be depended on by both interface
and implementation
packages. I think in that case these two wouldn’t need the ..
parent directory in their configuration files, since they would just depend on the types
package directly. The main drawback would be needing to build the dar
s sequentially, but that can be taken care of outside of damlc
.