module-management-0.20.4: Clean up module imports, split and merge modules

Safe HaskellNone
LanguageHaskell98

Language.Haskell.Modules.Split

Synopsis

Documentation

splitModule Source

Arguments

:: MonadClean m 
=> (Maybe Name -> ModuleName)

Map each symbol name to the module it will be moved to. The name Nothing is used for instance declarations.

-> FilePath

The file containing the input module.

-> m [ModuleResult] 

Split the declarations of the module in the input file into new modules as specified by the symToModule function, which maps symbol name's to module names. It is permissable for the output function to map one or more symbols to the original module. The modules will be written into files whose names are constructed from the module name in the usual way, but with a prefix taken from the first element of the list of directories in the SourceDirs list. This list is just ["."] by default.

splitModuleDecls Source

Arguments

:: MonadClean m 
=> FilePath

The file containing the input module.

-> m [ModuleResult] 

Split each of a module's declarations into a new module. Update the imports of all the modules in the moduVerse to reflect the split. For example, if you have a module like

module Start (a, b, (.+.)) where
import
a = 1 + a
b = 2
c = 3
c' = 4
(.+.) = b + c

After running splitModuleDecls "Start.hs" the Start module will be gone. The a and b symbols will be in new modules named Start.A and Start.B. Because they were not exported by Start, the c and c' symbols will both be in a new module named Start.Internal.C. And the .+. symbol will be in a module named Start.OtherSymbols. Note that this module needs to import new Start.A and Start.Internal.C modules.

If we had imported and then re-exported a symbol in Start it would go into a module named Start.ReExported. Any instance declarations would go into Start.Instances.

splitModuleBy Source

Arguments

:: MonadClean m 
=> (Maybe Name -> ModuleName)

Function mapping symbol names of the input module to destination module name.

-> ModuleInfo

The parsed input module.

-> m [ModuleResult] 

Do splitModuleBy with the default symbol to module mapping (was splitModule)

defaultSymbolToModule Source

Arguments

:: ModuleInfo

Parent module name

-> Maybe Name 
-> ModuleName 

This can be used to build the function parameter of splitModule, it determines which module should a symbol be moved to.