[Haskell-cafe] Testing and module export lists

Roel van Dijk vandijk.roel at gmail.com
Thu Feb 25 08:00:52 EST 2010

What I usually do in such a case is create a separate internal
module. The internal module exports everything. Then create a
module which defines the public interface. This module simple
reexports symbols from the internal module. Now you can create a
Test module which has full access to all internal symbols.

module Internal where
a = 1
b = 2
secret = 42

module Public ( a, b ) where
import Internal ( a, b )

module Test where
import Internal ( secret )
test = assert $ isUltimateAnswer secret

On Wed, Feb 24, 2010 at 10:17 AM, Magnus Therning <magnus at therning.org> wrote:
> How do people who like unit testing / property testing deal with export lists?
> 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?
> /M

More information about the Haskell-Cafe mailing list