
I have a module which defines data structures and their functions for a program. I have another module which defines show methods for the structures. Both modules have a substantial amount of code, and I would prefer to keep them separate. However, the show methods require access to internal data structures, which would not normally be exported. Furthermore, many modules do not require the show functions. Is there any solution to this, other than an intermediate module which imports the data module, and only exports the required names?

On Tue, Nov 09, 2010 at 07:00:59PM +0200, John Smith wrote:
I have a module which defines data structures and their functions for a program. I have another module which defines show methods for the structures. Both modules have a substantial amount of code, and I would prefer to keep them separate. However, the show methods require access to internal data structures, which would not normally be exported. Furthermore, many modules do not require the show functions. Is there any solution to this, other than an intermediate module which imports the data module, and only exports the required names?
I have wanted this, too (in the context of writing tests, where I want to test the unexported internals of a module). But unfortunately there is no way to do it other than the method you cite (to have a module which just imports the other module and only exports certain things). In several of my projects I follow the pattern of having a bunch of modules that export everything, and then a single module that imports all the other modules and only re-exports selected things; the intention is that users will just import the single module. -Brent
participants (2)
-
Brent Yorgey
-
John Smith