Confused by the qualified imports

Hi, I was looking into Gloss examples for usage of Repa arrays. For example the Snow example (http://code.ouroborus.net/gloss/gloss-stable/gloss-examples/raster/Snow/Main...). What I do not get is that there is qualified import of the Repa package, but the "Z" and ":." are used without the prefix. When I some times accidentally omit the prefix the ghc always yell at me. What em I missing? Thanks, Libor

If you use "import qualified Data.Array.Repa as R" then you have to specify
R in front of every function, operator, or type.
But if you use "import Data.Array.Repa as R" without the qualified keyword,
then you only have to use it when it would be ambiguous which module your
function or type comes from (ie. you had multiple modules imported without
qualification).
On Sun, Jan 6, 2013 at 11:30 AM, Libor Wagner
Hi,
I was looking into Gloss examples for usage of Repa arrays. For example the Snow example ( http://code.ouroborus.net/gloss/gloss-stable/gloss-examples/raster/Snow/Main...). What I do not get is that there is qualified import of the Repa package, but the "Z" and ":." are used without the prefix. When I some times accidentally omit the prefix the ghc always yell at me. What em I missing?
Thanks, Libor
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Sun, Jan 6, 2013 at 11:30 AM, Libor Wagner
I was looking into Gloss examples for usage of Repa arrays. For example the Snow example ( http://code.ouroborus.net/gloss/gloss-stable/gloss-examples/raster/Snow/Main...). What I do not get is that there is qualified import of the Repa package, but the "Z" and ":." are used without the prefix. When I some times accidentally omit the prefix the ghc always yell at me. What em I missing?
It's not a fully qualified import (no "qualified" keyword), so names are available both with and without the prefix. This means that you can use names that don't collide with other local or imported bindings without the prefix, but you need to use the prefix if you do need to disambiguate names that colide. For one example, Data.Array.Repa exports a binding "zipWith" --- but so does the Prelude, so you can't use that name unqualified because the compiler doesn't know which one you mean. (:.), on the other hand, is specific to Repa (at least with the imports in your example) so does not need qualification. (You could also get around this by explicitly importing the Prelude with a "hiding (zipWith)" clause.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (3)
-
Brandon Allbery
-
David McBride
-
Libor Wagner