[Haskell-cafe] Parent Modules: Common Functions or Re-Exportation?

Malcolm Wallace malcolm.wallace at me.com
Fri May 16 20:21:21 UTC 2014

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.


More information about the Haskell-Cafe mailing list