Description
Generate code for importing directories automatically.
Description
This module helps to automatically generate code for importing all the haskell files from directories.
Synopsis
For cabal inited project, we customize Setup.hs file to generate the importing code.
Be sure to modify the
build-typefield in the.cabalfile fromSimpletoCustom.Then modify the
mainfunction inSetup.hsto generate importing code by either header file or a module file.
Setup.hs:
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"
defaultMainTarget.hs: (by header)
{-# LANGUAGE CPP #-}
module Target where
#include "imports.header"
func = Export.funcFromSomeWhere
Target.hs: (by module)
module Target where
import qualified ImportAll
func = ImportAll.funcFromSomeWhere