Haskell Language Modules Qualifying Imports

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any Haskell Language Question?