odd problem with export list of System.IO

Hi. Maybe I'm missing something, but I don't understand why the following program: module Main where import System.IO (Handle, withFile, ReadMode) main = do return fails to compile, with a Module `System.IO' does not export `ReadMode' Thanks Manlio Perillo

On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo
Hi.
Maybe I'm missing something, but I don't understand why the following program:
module Main where import System.IO (Handle, withFile, ReadMode)
You want to import IOMode(..), not ReadMode. The latter is a data constructor of the IOMode type. Cheers, Johan

Johan Tibell ha scritto:
On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo
wrote: Hi.
Maybe I'm missing something, but I don't understand why the following program:
module Main where import System.IO (Handle, withFile, ReadMode)
You want to import IOMode(..), not ReadMode. The latter is a data constructor of the IOMode type.
import System.IO (Handle, withFile, IOMode(ReadMode)) solved the problem, thanks. However, why individual data constructors of the IOMode type are not exported? Thanks Manlio

On 2009 Mar 1, at 9:55, Manlio Perillo wrote:
Johan Tibell ha scritto:
On Sun, Mar 1, 2009 at 3:07 PM, Manlio Perillo
wrote: Hi.
Maybe I'm missing something, but I don't understand why the following program:
module Main where import System.IO (Handle, withFile, ReadMode) You want to import IOMode(..), not ReadMode. The latter is a data constructor of the IOMode type.
However, why individual data constructors of the IOMode type are not exported?
You asked for an explicit export list, why are you surprised that things not in that export list aren't exported? If you're asking why an individual constructor needs a type with it, it's because it's only meaningful in the context of that type, if you hand the compiler ReadMode without the IOMode definition, it wouldn't be able to do anything useful with it. (You could think if it as: ReadMode is IOMode[0] (not Haskell syntax, but internally ReadMode has the 0th constructor slot in the IOMode type), WriteMode is IOMode[1], you need IOMode for either to be useful/ meaningful.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (3)
-
Brandon S. Allbery KF8NH
-
Johan Tibell
-
Manlio Perillo