Generate code for importing directories automatically

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed by Cindy Wang (CindyLinz)

This module helps to automatically generate code for importing all the haskell files from directories.


For cabal inited project, we customize Setup.hs file to generate the importing code.

  • Be sure to modify the build-type field in the .cabal file from Simple to Custom.

  • Then modify the main function in Setup.hs to generate importing code by either header file or a module file.


import Distribution.Simple
import System.Imports (writeImportsHeader, writeImportsModule)

main = do
  writeImportsHeader "imports.header" "Export" "Some.Where" "Some/Where"
  -- or
  writeImportsModule "ImportAll.hs" "ImportAll" "Some.Where" "Some/Where"


Target.hs: (by header)

module Target where

#include "imports.header"

func = Export.funcFromSomeWhere

Target.hs: (by module)

module Target where

import qualified ImportAll

func = ImportAll.funcFromSomeWhere
Depends on 4 packages:
Used by 1 package:
comments powered byDisqus