Haskell Language Modules Qualifying Imports


When multiple modules define the same functions by name, the compiler will complain. In such cases (or to improve readability), we can use a qualified import:

import qualified Data.Stream as D

Now we can prevent ambiguity compiler errors when we use map, which is defined in Prelude and Data.Stream:

map (== 1) [1,2,3] -- will use Prelude.map
D.map (odd) (fromList [1..]) -- will use Data.Stream.map

It is also possible to import a module with only the clashing names being qualified via import Data.Text as T, which allows one to have Text instead of T.Text etc.