
On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic
On 24 February 2010 20:17, Magnus Therning
wrote: I often find that I do want an export list to reduce clutter in the finished code, but for testing I'd like to expose everything in a module. Is there a nice way to deal with this (using the C pre-processor would not qualify as "nice" ;-)? Maybe there's a switch that causes GHC to simply ignore the export list of a module and export everything?
If you start a function name with an underscore, it is "implicitly exported" by GHC (I can't find the actual documentation page at the moment however). Whilst it may not appear in the export list, you are still able to call it from outside the module.
This will, however, result in "ugly" function names as well as possibly still have those items appear in the haddock documentation...
Wow, I'd never heard of that feature. I currently export everything because under development it's too much hassle to maintain export lists. However when modules stabilize I think export lists are a good idea because then GHC can warn about unused functions and and hopefully eliminate internal bindings if they are all inlined. However, testing individual functions is much easier to understand and leads to shorter and less brittle tests, with clearer failures. So when the time comes I'll probably use #ifdef. That way I can run presumably ghci with -DTESTING as well and bypass the other annoying thing about export lists, which is that you have to get ghci to byte compile to see the internal symbols. It's not that much work to add #ifdef to each export list especially compared to the work of writing it in the first place, but it would still be nicer if there were a compiler flag that did this explicitly. The underscore thing seems sub-optimal to me because it doesn't help you with unused functions or dead code elimination.