[Haskell-cafe] odd problem with export list of System.IO

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sun Mar 1 10:50:34 EST 2009

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 <manlio_perillo at libero.it 
>> > 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/ 

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090301/d67d9020/PGP.bin

More information about the Haskell-Cafe mailing list