Hiding top level declaration with tilde

Ramin Honary ramin.honary at gmail.com
Thu Jan 9 07:46:28 UTC 2014


Hello,

I did some Googling, and read a bit through the Haskell 2010 report,
Chapter 5 "Modules," and searched through the Haskell-prime Trac tickets
and can't really find anything on this. I don't know if it has ever been
suggested before, or the reasoning for how export lists work the way they
do.

So as we all know, when there is no exports list in a module declaration,
everything in the top level is exported by default. If you provide an
exports list, everything is hidden except what you declare in the exports
list.

I think a good way to hide things without an exports list might be to
simply prefix the type signature with a tilde character. For example:

    module M where

    ~type A = ()
    ~newtype B = B ()
    ~data C = MkB1 () | MkB2 ()

    ~abc :: ()
    abc = ()

    increment :: Int -> Int
    increment = (+1)

So in this example, the module M would only export the "increment"
function, everything else would be hidden.

Right now, this would produce a compile-time error like:
    Invalid type signature: ~abc :: ()

I propose making this kind of expression legal and effecting whether or not
the symbol is exported.

The only disadvantage I can think of is that tilde is generally reserved
for making things more lazy, and using tilde in a way that has nothing to
do with lazyness, it could make the language a bit more confusing.
Otherwise I think it is very practical.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-prime/attachments/20140109/644481f7/attachment.html>


More information about the Haskell-prime mailing list