I'm working on a Haskell project and I started out by organizing it like this:
blah.hs holds the majority of the codeblah_main.hs has the main programblah_test.hs has the test cases.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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With