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

Add a module-prefixes field to rename all modules in a pkg #6105

Merged
merged 3 commits into from
May 28, 2020

Conversation

cocreature
Copy link
Contributor

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

changelog_end

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

Copy link
Contributor

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome! Great work. Thank you so much.

.. code-block:: yaml

module-prefixes:
foo-1.0.0: Foo1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use a prefix with a dot, like Foo.Bar, as well? If not, should we consider making it possible? Either way, let's document what is possible in this regard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we just append it. I’ll document it.


It is also possible to add a prefix to all modules in a package using
the ``module-prefixes`` field in your ``daml.yaml``. For the example
above you can use the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some motivation why you would want to do this here? Or shall we add something to the upgrading docs and reference it from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section is about handling module name collisions so the motivation is there but I’ll try to make it a bit clearer.

cocreature and others added 3 commits May 28, 2020 12:13
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
…ging/Metadata.hs

Co-authored-by: Martin Huschenbett <martin.huschenbett@posteo.me>
changelog_begin
changelog_end
@cocreature cocreature requested a review from a user May 28, 2020 10:13
@cocreature cocreature requested a review from a user May 28, 2020 10:13
@mergify mergify bot merged commit 2ccbd7f into master May 28, 2020
@mergify mergify bot deleted the module-prefix branch May 28, 2020 10:57
@garyverhaegen-da
Copy link
Contributor

That's really neat. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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