LOS
LOS

Reputation: 523

QuickCheck catch-22

I'm working on a Haskell project and I started out by organizing it like this:

The problem with this is that restricting the functions exported by blah.hs means restricting the functions that can be tested from blah_test.hs. Is there a good way around this issue? Because I'd really like to write test code for some of the "internal" functions that aren't being exported by blah.hs.

Thanks, Lee

Upvotes: 12

Views: 259

Answers (2)

Michael Snoyman
Michael Snoyman

Reputation: 31335

I agree with Mikhail over all, but in some circumstances it's not really possible to make such a split. In those cases, I would recommend using the CPP (C Pre-Processor) extension, along the lines of:

module Blah
    ( public
#if TEST
    , private
#endif
    ) where

Upvotes: 8

Mikhail Glushenkov
Mikhail Glushenkov

Reputation: 15078

Move internal functions from the Blah.* modules to Blah.Internal.* . You can hide internal modules from the users of your library by listing them in the other-modules field in the blah.cabal file (instead of exposed-modules, where you list all modules visible to the users). Look at Hakyll's .cabal file for an example.

Upvotes: 18

Related Questions