Syntax question regarding 'import'

Hi, About this teste code: module Main (main) where { import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ; blo = xor 10 10 :: Int ; main = return () } Data.Bits is in the 'hiding' list. According to the syntax reference, this seems not to be allowed. GHC allows it, but do allow following code to use 'xor' from Data.Bits. I think this is correct, since 'xor' was exported by Foreign unqualified, but does 'Data.Bits' in that list mean something or it's just ignored? Haskell syntax allows a comma at the end of names to be imported or exported, like in the second line. What does that mean? Thanks, Maurício

Hello Maurício, Tuesday, November 4, 2008, 3:47:17 PM, you wrote:
Haskell syntax allows a comma at the end of names to be imported or exported, like in the second line. What does that mean?
it simplifies editiing of lists: you can add/remove lines without changing surrounding ones: import XXX hiding( aaa, bbb, ccc, ) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

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 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.

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
participants (3)
-
Achim Schneider
-
Bulat Ziganshin
-
Maurício