diagrams-builder-0.4: hint-based build service for the diagrams graphics EDSL.

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Diagrams.Builder.Modules

Description

Tools used by diagrams-builder for manipulating Haskell modules.

Synopsis

Documentation

createModuleSource

Arguments

:: Maybe String

Module name to use

-> [String]

LANGUAGE pragmas to add

-> [String]

Imports to add

-> [String]

Source code

-> Either String Module 

Extend some snippets of source code into a proper module, by combining them intelligently (preserving imports, pragmas, etc.), (possibly) giving it a different name, and adding LANGUAGE pragmas and imports if necessary. Only those pragmas and imports which are not already included in the code will be added.

Returns the updated module, or an error message if parsing failed.

doModuleParse :: String -> Either String ModuleSource

Run the haskell-src-exts parser on a String representing some Haskell code, producing a Module or an error message.

unLit :: String -> StringSource

Remove all the literate comments and bird tracks from a literate Haskell file. Has no effect on non-literate source.

replaceModuleName :: String -> Module -> ModuleSource

Replace the name of a module.

deleteExports :: Module -> ModuleSource

Delete module exports.

addPragmas :: [String] -> Module -> ModuleSource

Add some LANGUAGE pragmas to a module if necessary.

addImports :: [String] -> Module -> ModuleSource

Add some imports to a module if necessary.

combineModules :: Module -> Module -> ModuleSource

Combine two modules into one, with a left bias in the case of things that can't be sensibly combined (e.g. the module name). Note that combining multiple imports of the same module with different import specifications (qualification, hiding, explicit import) is unlikely to work sensibly.

getModuleName :: ModuleName -> StringSource

Convert a ModuleName to a String.