Hiding module *exports*

amindfv at gmail.com amindfv at gmail.com
Mon Oct 27 13:55:13 UTC 2014


El Oct 27, 2014, a las 7:42, Herbert Valerio Riedel <hvr at gnu.org> escribió:

> On 2014-10-26 at 20:28:41 +0100, Tom Murphy wrote:
> 
> [...]
> 
>>    module Foo hiding (Lockbox(MkLockbox), internalFunction) where
>> 
>> I think its semantics are immediately clear to the reader.
>> 
>> There's a little bit of bikeshedding that needs to happen (e.g. is "hiding
>> (Foo(..))" sufficient to hide the type Foo and not just its constructors),
>> but are people +1 on this? I've frequently wanted this behavior.
> 
> PS: As for semantics, I'd suggest to have
> 
>  module Foo hiding (Lockbox(MkLockbox), internalFunction) where
> 
> the same effect moving the definitions of `Foo` into an hidden/internal
> module `_Foo` and having `Foo` re-export it in the following way:
> 
>  module Foo (module _Foo) where
>  import _Foo hiding (Lockbox(MkLockbox), internalFunction)
> 
> that should result the least surprise IMHO
> 

Right -- hiding a type necessarily hides its constructors (and importing a constructor necessarily imports its type), which actually implies an obvious semantics. So there's less to bikeshed than I had thought.

Tom


More information about the Glasgow-haskell-users mailing list