Skip to content

Export Lists

Export lists are the way to distinguish between public functions, types, and type classes that constitute the public API of our module, and private functions, types, and type classes that are implementation details we do not share with the outside world. The reason to hide private implementation details from the outside world is the same as for having private data members and methods in classes in object-oriented languages: By hiding these implementation details from other modules, we are free to change these implementation details, for example to make our module more efficient. If this does not result in a change of the public API of our module, any code that relies on our module still compiles and continues to work. If we expose implementation details to the outside world, then the implementation of other modules may depend on these implementation details. If we change them, we may break other projects that depend on our module.

When defining a module using

MyFancyModule.hs
module MyFancyModule where

this does not hide anything defined in our module from the outside world; every function, data type or type class defined in our module is visible to (i.e., can be imported by) other modules. It is as if we had a Java file where every class, method, and class member is declared to be public.

Recently, GHC changed its behaviour to give us a warning whenever we have such an open module that exports everything. We should be explicit about what we want to export.