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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improve docs and fix broken suggestion
changelog_begin
changelog_end
  • Loading branch information
cocreature committed May 28, 2020
commit 79647101f49fbd42145e2372c71626b259193f63
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module DA.Daml.Options.Packaging.Metadata
) where

import Data.Aeson
import Data.List
import DA.Daml.Package.Config ()
import Data.Map.Strict (Map)
import qualified Data.Text as T
Expand Down Expand Up @@ -54,7 +53,7 @@ renamingToFlag unitId prefix modules =
[ ( Ghc.mkModuleName s
, Ghc.mkModuleName (Ghc.moduleNameString prefix ++ "." ++ s))
| m <- modules
, s = T.unpack (LF.moduleNameString m)
, let s = T.unpack (LF.moduleNameString m)
]
}

Expand Down
10 changes: 8 additions & 2 deletions docs/source/daml/reference/packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ This will alias the ``X`` in ``foo-1.0.0`` as ``Foo1.X``, and alias the ``X`` in
import qualified Foo2.X

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:
the ``module-prefixes`` field in your ``daml.yaml``. This is
partiuclarly useful for upgrades where you can map all modules of
version ``v`` of your package under ``V$v``. For the example above you
can use the following:

.. code-block:: yaml

Expand All @@ -243,3 +245,7 @@ above you can use the following:

That will allow you to import module ``X`` from package ``foo-1.0.0``
as ``Foo1.X`` and ``X`` from package ``-foo-2.0.0`` as ``Foo2``.

You can also use more complex module prefixes, e.g., ``foo-1.0.0:
Foo1.Bar`` which will make module ``X`` available under
``Foo1.Bar.X``.