…such that consuming code can only import the ones exported but not other ones? As a way to keep code private to a module.
It somewhat depends on what your goal is. There is no way to limit exports in Daml-LF or across
data-dependencies so if your goal is to enforce internal invariants or something along those lines you’re out of luck.
You can limit exports in Daml within a package (and within
dependencies) using Haskell export lists, e.g.,
module M (f) where
will only export the function
f. See 5 Modules for more details on those.
Given that they are not respected in Daml-LF those only serve as guidance to users not as a way to enforce invariants so I view that more as documentation on the intended API of a module.
See this post about using namespaces cleverly:
And also this for a discussion of enforcement of scope through the API, which I think you may be alluding to: