Monday, July 27, 2009

Haskell 'import qualified'

Haskell's module system is a bit weird.  Consider the following:

import qualified Data.List as L
import qualified Data.Char as L

x = L.concat []
y = L.toUpper 'c'

How can this make sense?  I was interpreting

import qualified Data.List as L


structure L = Data.List

in SML.

Apparently the qualified import just makes a new namespace and
dumps all the names from the modules into it.  If there is a conflict,
you simply can't use the name.  For instance, if it was Data.Map and Data.List,
then L.union would be ambiguous.

No comments:

Post a Comment