[Haskell-cafe] Unexported functions are evil

Peter Simons simons at cryp.to
Sun May 15 06:29:11 EDT 2005


Please pardon the tendentious subject, but I felt like
making a clear statement. ;-)

I was wondering: Is there any reason why you would have a
function in one of your modules and _not_ export it?

I ask because I have _never_ had problems with a module
exporting too much, but I have had problems with modules
exporting too little quite frequently.

The reason why I like purely functional languages like
Haskell is that it is virtually impossible to write code
that cannot be reused. So why would you exclude other
modules from reusing you code?

The only reason I could think of is that a function is
considered to be "internal", meaning: You don't want users
of the module to rely on the function still being there (or
still working the same way) in any of the next revisions.

On those occasions, however, why not put the function into a
module, say "Foo.Bar.Private" and import it into "Foo.Bar"
from there? Then those people who enjoy playing with fire
_can_ use it, and everybody else will not.

Is there something I missed?

Peter



More information about the Haskell-Cafe mailing list