Modules and their explicit export lists (are an annoyance)

Hi everybody, I'd like some input on other peoples' thoughts on this. Recently, I played around with a library that uses an explicit export list. While there are reasons for having one: - efficiencey (inlining in the module) - encapsulation in practice, it seems to me that they are more annoying than useful. For once, it would think that ghc should produce efficient good across modules with -O / -O2 anyway. But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)). So, should I really fork a library just to be able to add a function? Btw. there are libraries, where an explicit export list is used, that export the right amount of information. For example, in 'vector' enough is exported to allow you to extend unboxed vectors.

I write an export list because I want to help Haddock. It suffices to export a constructor with (..) for this, if I intend to. How much to export is always politics, bargaining, negotiation, social dynamics. There will always be someone annoyed. Exporting too much reduces annoyance now by re-paying for annoyance plus interest in future when an exported item will be withdrawn or visibly changed. Discuss with the authors if you believe that more should be exported.

Hi, Christian. Here is my humble and somewhat vague thoughts. I think that export list is reasonable for commonly used and stable (ancient) library. Export list is a contract between library's author and user. Though current Haskell rules force author to have one and only one contract with all the people in the world. E.g. in law there is no such restriction. Assuming that (using/not using) an unstable function in the library is responsibility of library's user (not author), there may be: - declaration "import hidden" for importing everything; - compiler option for banning "import hidden"; - several export lists (in separate files) for different type of users. On 19.06.10 21:38, Christian Höner zu Siederdissen wrote:
Hi everybody,
I'd like some input on other peoples' thoughts on this. Recently, I played around with a library that uses an explicit export list. … But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)). So, should I really fork a library just to be able to add a function?
-- Best regards, Roman Beslik.

Another useful extension here could be "friend modules" and "friend
packages," similar to friend declarations in C++. Then a restricted
set of modules or packages could see inside a package to extend it,
even as the package is closed to the rest of the world.
Alex
On Sat, Jun 19, 2010 at 1:29 PM, Roman Beslik
Hi, Christian. Here is my humble and somewhat vague thoughts. I think that export list is reasonable for commonly used and stable (ancient) library. Export list is a contract between library's author and user. Though current Haskell rules force author to have one and only one contract with all the people in the world. E.g. in law there is no such restriction. Assuming that (using/not using) an unstable function in the library is responsibility of library's user (not author), there may be: - declaration "import hidden" for importing everything; - compiler option for banning "import hidden"; - several export lists (in separate files) for different type of users. On 19.06.10 21:38, Christian Höner zu Siederdissen wrote:
Hi everybody,
I'd like some input on other peoples' thoughts on this. Recently, I played around with a library that uses an explicit export list. … But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)). So, should I really fork a library just to be able to add a function?
-- Best regards, Roman Beslik.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Encapsulation is essential for constructing robust software.
How could we get rid of that and claim to have a serious language?
On Sat, Jun 19, 2010 at 8:38 PM, Christian Höner zu Siederdissen
Hi everybody,
I'd like some input on other peoples' thoughts on this. Recently, I played around with a library that uses an explicit export list. While there are reasons for having one:
- efficiencey (inlining in the module) - encapsulation
in practice, it seems to me that they are more annoying than useful. For once, it would think that ghc should produce efficient good across modules with -O / -O2 anyway. But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)).
So, should I really fork a library just to be able to add a function?
Btw. there are libraries, where an explicit export list is used, that export the right amount of information. For example, in 'vector' enough is exported to allow you to extend unboxed vectors.
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On Sat, Jun 19, 2010 at 08:38:52PM +0200, Christian Höner zu Siederdissen wrote:
But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)).
I think this is another problem. Sure, without export lists you *currently* can't hide those constructors. However, languages like Java don't have export lists as well. Imagine if we could write this in Haskell: private data Foo a = Foo a (Foo (Either a a)) Now, about the exports lists: they are useful to hide internal functions. I have many modules where I define functions that are not interesting outside that module. Cheers, -- Felipe.

On Sat, Jun 19, 2010 at 6:00 PM, Felipe Lessa
On Sat, Jun 19, 2010 at 08:38:52PM +0200, Christian Höner zu Siederdissen wrote:
But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)).
I think this is another problem. Sure, without export lists you *currently* can't hide those constructors. However, languages like Java don't have export lists as well. Imagine if we could write this in Haskell:
private data Foo a = Foo a (Foo (Either a a))
But that's just a syntactical difference. I suspect whether you prefer to put visibility directly on the definition or collect it all in one place depends on personal taste and what you're used to.

On Sat, Jun 19, 2010 at 07:23:50PM -0700, Evan Laforge wrote:
On Sat, Jun 19, 2010 at 6:00 PM, Felipe Lessa
wrote: On Sat, Jun 19, 2010 at 08:38:52PM +0200, Christian Höner zu Siederdissen wrote:
But the more important thing is, that it makes extending module functionality a pain (eg. if a constructor is not exported using (..)).
I think this is another problem. Sure, without export lists you *currently* can't hide those constructors. However, languages like Java don't have export lists as well. Imagine if we could write this in Haskell:
private data Foo a = Foo a (Foo (Either a a))
But that's just a syntactical difference. I suspect whether you prefer to put visibility directly on the definition or collect it all in one place depends on personal taste and what you're used to.
That's my point. Hiding a constructor is orthogonal to using export lists. Cheers, -- Felipe.
participants (7)
-
Albert Y. C. Lai
-
Alexander Dunlap
-
Christian Höner zu Siederdissen
-
Evan Laforge
-
Felipe Lessa
-
Lennart Augustsson
-
Roman Beslik