# Exported for tests only: Precise control over API visibility with custom warnings

**URL:** <https://discourse.haskell.org/t/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/12533>\
**Category:** Links\
**Created:** [July 22, 2025, 11:49am UTC](https://discourse.haskell.org/t/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/12533 "2025-07-22T11:49:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rumaan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/rumaan/32/5158_2.png) [@rumaan](https://discourse.haskell.org/u/rumaan)\
**Post date:** [July 22, 2025, 11:49am UTC](https://discourse.haskell.org/t/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/12533/1 "2025-07-22T11:49:00Z")

</div>

Last December I wrote a post on the Scrive engineering blog regarding user-defined warnings, and how they can be used to convey usage of unsafe constructors

> **[Exported for tests only: Precise control over API visibility with custom...](https://tech.scrive.com/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/)**
>
> This article describes a pattern made possible by recent advances in GHC 9.8, to allow library authors to control how internal data constructors can be labelled as unsafe for human consumption, while needing to be exported for test suites.
> 
> 
> Making...

---

<div class="post-metadata">

**Author:** ![eldritch-cookie](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/eldritch-cookie/32/4130_2.png) [@eldritch-cookie](https://discourse.haskell.org/u/eldritch-cookie)\
**Post date:** [July 24, 2025, 1:05pm UTC](https://discourse.haskell.org/t/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/12533/2 "2025-07-24T13:05:49Z")

</div>

shouldn’t you qualify  
-x-unsafe-internals with at least your package? -x-mypackage-unsafe-internals ? otherwise a library that uses this technique couldn’t depend on another library that also uses this technique without issues?

---

<div class="post-metadata">

**Author:** ![rumaan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/rumaan/32/5158_2.png) [@rumaan](https://discourse.haskell.org/u/rumaan)\
**Post date:** [July 24, 2025, 1:17pm UTC](https://discourse.haskell.org/t/exported-for-tests-only-precise-control-over-api-visibility-with-custom-warnings/12533/3 "2025-07-24T13:17:09Z")

</div>

True, although when you start to depend on more than 100 dependencies, conventions are really useful in this regard. 🙂
