Parent Modules: Common Functions or Re-Exportation?

So as a relatively long term user of haskell at this point, one issue which I've never found a simple solution to is the one stated in the thread. That is, given modules Foo, Foo.Bar, and Foo.Baz, should Foo reexport Bar and Baz, or should Foo provide common functions for Bar and Baz? In the first case, the common functions would have to be provided by some third module Foo.Util, which for some reason I find unsatisfying, as it means all my my modules have these Util after Util after Util module floating aroudn. My natural tendency is follow the second case, but then of course when it comes to actually using the code that I've written, I no longer have such a nicely exposed interface outside of the particular library. One simply can't eat ones cake and have it too. Maybe this problem is just silly, but perhaps others have always been left feeling ambivalent across similar lines, and have somehow found a pleasant solution for when this particular crossroads is reached? Cheers, - Sacha Sokoloski

On 16 May 2014, at 18:13, Sacha Sokoloski wrote:
So as a relatively long term user of haskell at this point, one issue which I've never found a simple solution to is the one stated in the thread. That is, given modules Foo, Foo.Bar, and Foo.Baz, should Foo reexport Bar and Baz, or should Foo provide common functions for Bar and Baz?
The way we tend to organise things at my workplace, we have Foo.Internal -- datatypes, implementation details Foo.Bar -- Bar-like utilities over Foo Foo.Quux -- Quux-like utilities over Quux Foo -- some useful subset of the above, hiding the implementation details For instance, often the datatypes will be exported in full from Foo.Internal, but abstractly from Foo. The real constructors and fieldnames can be used from Foo.Bar and Foo.Quux, but not externally. We actually use home-grown compiler restrictions, to ensure that Foo.Internal can only be imported from other modules under the Foo tree, so that the details do not leak. Regards, Malcolm
participants (2)
-
Malcolm Wallace
-
Sacha Sokoloski