Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give users more tools to deal with ghc package name shadowing in dependencies and data-dependencies. #4948

Closed
ghost opened this issue Mar 11, 2020 · 2 comments · Fixed by #6105
Assignees
Labels
component/packaging discussion Things to be discussed and decided language Language team work

Comments

@ghost
Copy link

ghost commented Mar 11, 2020

When packages have the same ghc package name, such as when importing multiple versions of the same package, or old versions of the current package, package qualified imports don't work by default. The user needs to a package flag in build-options to rename modules. This is really unintuitive, so I think we should add some support for dealing with package imports in daml.yaml, e.g. by giving the package an alias:

dependencies:
- daml-stdlib
- daml-prim
- package: foo-1.0.3
  alias: foo1

So you could disambiguate modules by using package qualified imports:

import "foo1" Foo as Foo1

Alternatively, this could be solved by adding a prefix to module names:

dependencies:
- daml-stdlib
- daml-prim
- package: foo-1.0.3
  prefix: Foo1

so you can just use a regular import,

import Foo1.Foo

I think the latter is a little cleaner for users, since you perform any necessary module renaming in a consistent place and you don't have to use package qualified import syntax, but I don't know which one is easier to implement.

@ghost ghost added discussion Things to be discussed and decided language Language team work component/packaging labels Mar 11, 2020
@ghost ghost mentioned this issue Mar 11, 2020
6 tasks
@cocreature
Copy link
Contributor

On the other hand, renaming packages doesn’t seem that much easier than renaming modules (which arlready works). I guess providing an alias for the package is nicer if you have lots of collisions.

@cocreature
Copy link
Contributor

Actually looking at this again, the latter option of having a prefix should be trivial to implement. That’s just syntactic sugar around the --package flag that we already have.

@cocreature cocreature self-assigned this May 26, 2020
cocreature added a commit that referenced this issue May 26, 2020
This PR adds a `module-prefixes` field to `daml.yaml` a a shorthand
for specifying a `--package` flag that renames all modules in a
package to have the same prefix.

The docs are updated to describe how you can use this field and there
is a test case that makes sure it works.

fixes #4948

changelog_begin

- [DAML Compiler] You can now use the new ``module-prefixes`` field in
  ``daml.yaml`` to add a prefix to all modules from a dependency. This
  is particularly useful for handling colliding module names during
  upgrades. See
  https://docs.daml.com/daml/reference/packages.html#handling-module-name-collisions
  for more information.

changelog_end
cocreature added a commit that referenced this issue May 26, 2020
This PR adds a `module-prefixes` field to `daml.yaml` a a shorthand
for specifying a `--package` flag that renames all modules in a
package to have the same prefix.

The docs are updated to describe how you can use this field and there
is a test case that makes sure it works.

fixes #4948

changelog_begin

- [DAML Compiler] You can now use the new ``module-prefixes`` field in
  ``daml.yaml`` to add a prefix to all modules from a dependency. This
  is particularly useful for handling colliding module names during
  upgrades. See
  https://docs.daml.com/daml/reference/packages.html#handling-module-name-collisions
  for more information.

changelog_end
cocreature added a commit that referenced this issue May 28, 2020
This PR adds a `module-prefixes` field to `daml.yaml` a a shorthand
for specifying a `--package` flag that renames all modules in a
package to have the same prefix.

The docs are updated to describe how you can use this field and there
is a test case that makes sure it works.

fixes #4948

changelog_begin

- [DAML Compiler] You can now use the new ``module-prefixes`` field in
  ``daml.yaml`` to add a prefix to all modules from a dependency. This
  is particularly useful for handling colliding module names during
  upgrades. See
  https://docs.daml.com/daml/reference/packages.html#handling-module-name-collisions
  for more information.

changelog_end
@mergify mergify bot closed this as completed in #6105 May 28, 2020
mergify bot pushed a commit that referenced this issue May 28, 2020
* Add a module-prefixes field to rename all modules in a pkg

This PR adds a `module-prefixes` field to `daml.yaml` a a shorthand
for specifying a `--package` flag that renames all modules in a
package to have the same prefix.

The docs are updated to describe how you can use this field and there
is a test case that makes sure it works.

fixes #4948

changelog_begin

- [DAML Compiler] You can now use the new ``module-prefixes`` field in
  ``daml.yaml`` to add a prefix to all modules from a dependency. This
  is particularly useful for handling colliding module names during
  upgrades. See
  https://docs.daml.com/daml/reference/packages.html#handling-module-name-collisions
  for more information.

changelog_end

* Update compiler/damlc/daml-opts/daml-opts-types/DA/Daml/Options/Packaging/Metadata.hs

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>

* Improve docs and fix broken suggestion

changelog_begin
changelog_end

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/packaging discussion Things to be discussed and decided language Language team work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant