[Haskell-cafe] Re: Syntax question regarding 'import'

2008-11-04 Thread Achim Schneider
Maurcio [EMAIL PROTECTED] wrote:

 About this teste code:
 
 module Main (main) where {
 import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ;
 blo = xor 10 10 :: Int ;
 main = return ()
 }
 
You're only hiding the typeclass Data.Bits, not the function xor. To do
that, you have to write

import Foreign hiding (unsafePerformIO,Data.Bits(..))


Generally, I'd use 

import Foo(bar, Baz, Quux(..)) as F

(or even using qualified) instead of using hiding, it may be more
verbose but is way less confusing. Actually, I usually just write

import qualified Foo as F

and don't ever have to worry about name clashes.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Syntax question regarding 'import'

2008-11-04 Thread Maurí­cio

 About this teste code:

 module Main (main) where {
 import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ;
 blo = xor 10 10 :: Int ;
 main = return ()
 }


 You're only hiding the typeclass Data.Bits, not
 the function xor. To do that, you have to write

 import Foreign hiding (unsafePerformIO,Data.Bits(..))


 Generally, I'd use (...)
 import qualified Foo as F
 and don't ever have to worry about name clashes.

Agree. I'm asking this because I'm wrting my
syntax reference. Is that a GHC extension? Look at
this (from haskell 98 report sections 5.2 and
5.3):

export   - qvar
 | qtycon [(..) | ( cname1 , ... , cnamen )]
 | qtycls [(..) | ( var1 , ... , varn )]
 | module modid

import   - var
 | tycon [ (..) | ( cname1 , ... , cnamen )]
 | tycls [(..) | ( var1 , ... , varn )]

It seems 'modid's are included when exporting
names, but not when importing.

Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe