[Haskell-beginners] Confused by the qualified imports
Brandon Allbery
allbery.b at gmail.com
Sun Jan 6 18:01:53 CET 2013
On Sun, Jan 6, 2013 at 11:30 AM, Libor Wagner <liborwagner at gmail.com> wrote:
> 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.hs).
> 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 at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130106/34de2926/attachment.htm>
More information about the Beginners
mailing list