[Haskell-cafe] Are explicit exports and local imports desirable in a production application?

Ignat Insarov kindaro at gmail.com
Fri Sep 18 07:22:45 UTC 2020


Thank you Henning. This is true. When one wishes to provide an
abstract type, surely one would like to re-export the type
constructor, but not the associated data constructors — so explicit
exports become unavoidable. I have not accounted for this detail.

> >> You need explicit exports in the public interface, in my example module
> >> "A".
> >
> > How so?
>
> My example should be like so:
>
> module A.Internal where
>
> data T = Private Integer
>
>
> module A (
>     T,  -- do not export constructor
>     f,
>     ) where
>
> import A.Internal (T(Private))
>
> f :: FooBar
> f = do something with Private
>
>
> You would need the export list in A for exposing T, but not Private.


More information about the Haskell-Cafe mailing list