An import declaration makes definitions from another Haskell module available to the importing module. A basic import brings in everything named by the imported module’s export list, or everything when no export list exists. section 2.1.3
Use imports to control how modules share code:
- Import a module directly when its exported names do not conflict with names already in scope. section 2.1.3
- Qualify a name with its module, such as ModuleName.x, when different modules provide definitions with the same name. section 2.1.3 section 5.3
- Group related modules behind a top-level module that re-exports them, allowing clients to use one import instead of several. section 7.4.2
Importing Lib into Main
A module can export someFunc, and Main can import Lib before using it as its entry point: module Main where import Lib main :: IO () main = someFunc For larger projects, a Csv module can instead re-export Csv.Conversion and Csv.Types, so client modules import Csv once.
Listing 7.15 A re-export of modules
module Csv
( module Csv.Conversion, #1
module Csv.Types,
)
where
import Csv.Conversion #2
import Csv.Types
Inspect the re-export pattern that combines related CSV modules behind one public import. section 7.4.2












