Module visibility of data type constructors

Hello. I have a simple question for data type constructors visibility. Take a look: module Foo (Bar) where data Bar = Bar In ghc this allows me to use Bar, the type constructor, in another module, although it shouldn't be visible outside Foo. On the other hand, if I change Bar's definition as: data Bar = Baz Baz isn't visible outside Foo. Is this the correct behavior or is it bug in ghc? Cheers. -- Slavomir Kaslev

On Sat, Nov 04, 2006 at 09:39:39PM +0200, Slavomir Kaslev wrote:
To: haskell-cafe@haskell.org From: Slavomir Kaslev
Date: Sat, 4 Nov 2006 21:39:39 +0200 Subject: [Haskell-cafe] Module visibility of data type constructors Hello. I have a simple question for data type constructors visibility. Take a look:
module Foo (Bar) where data Bar = Bar
In ghc this allows me to use Bar, the type constructor, in another module, although it shouldn't be visible outside Foo. On the other hand, if I change Bar's definition as:
data Bar = Baz
Baz isn't visible outside Foo.
Is this the correct behavior or is it bug in ghc?
It's not the correct behavior. The question is whether the bug is in your code or in ghc (with me it's usually the former :-). I can't reproduce this with my ghc 6.4. Which version are you using? Can you post the other module you are talking about? matthias

On 11/4/06, Matthias Fischmann
On Sat, Nov 04, 2006 at 09:39:39PM +0200, Slavomir Kaslev wrote:
To: haskell-cafe@haskell.org From: Slavomir Kaslev
Date: Sat, 4 Nov 2006 21:39:39 +0200 Subject: [Haskell-cafe] Module visibility of data type constructors Hello. I have a simple question for data type constructors visibility. Take a look:
module Foo (Bar) where data Bar = Bar
In ghc this allows me to use Bar, the type constructor, in another module, although it shouldn't be visible outside Foo. On the other hand, if I change Bar's definition as:
data Bar = Baz
Baz isn't visible outside Foo.
Is this the correct behavior or is it bug in ghc?
It's not the correct behavior. The question is whether the bug is in your code or in ghc (with me it's usually the former :-).
I can't reproduce this with my ghc 6.4. Which version are you using? Can you post the other module you are talking about?
matthias
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFFTPl+TXPx/Y0ym6oRAibjAJ9uG6ZP37xOnCRRRAaraewnCn/tmQCgkZB/ xLL/q1iDHAhBUCuojOZsvuA= =jWQR -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Actually you're right. It was my mistake, I don't know what tricked me. I was evaluating in ghci, not noticing even (silly me) *Foo>. Sorry for the noise. I probably need some more coffe in this time of the day. -- Slavomir Kaslev

Slavomir,
module Foo (Bar) where data Bar = Bar
In ghc this allows me to use Bar, the type constructor, in another module, although it shouldn't be visible outside Foo. On the other hand, if I change Bar's definition as:
data Bar = Baz
Baz isn't visible outside Foo.
On terminology: in data T = D T is called a type constructor and is called a *data* constructor. Cheers, Stefan

On 11/5/06, Stefan Holdermans
data T = D
I wrote:
T is called a type constructor and is called a *data* constructor.
and obviously meant:
... and D is called a *data* constructor.
Yes, you are right. I am newcomer to Haskell, coming from the C++ world, and I certainly lack proper Haskell-ish terminology. I apologize for that. -- Slavomir Kaslev
participants (3)
-
Matthias Fischmann
-
Slavomir Kaslev
-
Stefan Holdermans