Hide internal modules but expose them for testing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Hide internal modules but expose them for testing

Georgi Lyubenov
Greetings,

I want to have internal modules which I do not expose at all. I also want to be able to test them.

This however also hides these modules from my tests.

The best way I have found to work around this is to include my entire source directory in the test suite (source-dirs). This however means that I can't reuse builds that didn't include the tests.

Is there some obvious and "best" solution that I am missing here? For reference I use Stack.

Thanks in advance!

=======
Georgi

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Hide internal modules but expose them for testing

Li-yao Xia-2

My preferred solution is to put all the implementation inĀ  Mylib.Internal.Foo modules that export everything, with the convention that it's not subject to versioning policies (so testing is really the only legitimate use), and reexport the public stuff in Mylib.Foo.

Li-yao


On 09:08, Mon, Jan 7, 2019 Georgi Lyubenov <[hidden email] wrote:
Greetings,

I want to have internal modules which I do not expose at all. I also want to be able to test them.

This however also hides these modules from my tests.

The best way I have found to work around this is to include my entire source directory in the test suite (source-dirs). This however means that I can't reuse builds that didn't include the tests.

Is there some obvious and "best" solution that I am missing here? For reference I use Stack.

Thanks in advance!

=======
Georgi
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Hide internal modules but expose them for testing

Alexander Vershilov
Hello Georgi,

while I prefer Internal convention and expose everything, and would
advice that as a way forward,
your use case is supported by Cabal. There is a way to define an
internal/sublibrary that is
visible in the package but not exposed outside. You can find relevant
documentation with examples
in Cabal docs:

https://cabal.readthedocs.io/en/latest/developing-packages.html#sublibs

On Mon, 7 Jan 2019 at 14:10, Li-yao Xia <[hidden email]> wrote:

>
> My preferred solution is to put all the implementation in  Mylib.Internal.Foo modules that export everything, with the convention that it's not subject to versioning policies (so testing is really the only legitimate use), and reexport the public stuff in Mylib.Foo.
>
> Li-yao
>
>
> On 09:08, Mon, Jan 7, 2019 Georgi Lyubenov <[hidden email] wrote:
>>
>> Greetings,
>>
>> I want to have internal modules which I do not expose at all. I also want to be able to test them.
>>
>> This however also hides these modules from my tests.
>>
>> The best way I have found to work around this is to include my entire source directory in the test suite (source-dirs). This however means that I can't reuse builds that didn't include the tests.
>>
>> Is there some obvious and "best" solution that I am missing here? For reference I use Stack.
>>
>> Thanks in advance!
>>
>> =======
>> Georgi
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.



--
Alexander
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Hide internal modules but expose them for testing

Vanessa McHale
In reply to this post by Georgi Lyubenov

As of recently you can have private libraries in a package. See e.g. my htoml-megaparsec package for an example: http://hackage.haskell.org/package/htoml-megaparsec where I use it to do exactly what you wanted.

On 1/7/19 2:08 AM, Georgi Lyubenov wrote:
Greetings,

I want to have internal modules which I do not expose at all. I also want to be able to test them.

This however also hides these modules from my tests.

The best way I have found to work around this is to include my entire source directory in the test suite (source-dirs). This however means that I can't reuse builds that didn't include the tests.

Is there some obvious and "best" solution that I am missing here? For reference I use Stack.

Thanks in advance!

=======
Georgi

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (499 bytes) Download Attachment