-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library and an executable that provide an easy API for a Haskell IDE -- -- Buildwrapper is an alternative to scion. It provides services to -- configure, build and give information on source files to help IDEs -- manage Haskell projects. You can use buildwrapper to build project and -- retrieve errors, get outline for each module source, get the type of -- something inside a source file, get lexer tokens, etc. Buildwrapper is -- used in the EclipseFP project (Eclipse plugins for Haskell -- development) @package buildwrapper @version 0.5.2 module Language.Haskell.BuildWrapper.Base -- | State type type BuildWrapper = StateT BuildWrapperState IO -- | the state we keep data BuildWrapperState BuildWrapperState :: String -> FilePath -> FilePath -> Verbosity -> String -> [String] -> BuildWrapperState -- | name of temporary folder tempFolder :: BuildWrapperState -> String -- | path to the cabal executable cabalPath :: BuildWrapperState -> FilePath -- | path of the project cabal file cabalFile :: BuildWrapperState -> FilePath -- | verbosity of logging verbosity :: BuildWrapperState -> Verbosity -- | flags to pass cabal cabalFlags :: BuildWrapperState -> String -- | extra arguments to cabal configure cabalOpts :: BuildWrapperState -> [String] -- | status of notes: error or warning data BWNoteStatus BWError :: BWNoteStatus BWWarning :: BWNoteStatus -- | location of a note/error data BWLocation BWLocation :: FilePath -> Int -> Int -> BWLocation -- | source file bwl_src :: BWLocation -> FilePath -- | line bwl_line :: BWLocation -> Int -- | column bwl_col :: BWLocation -> Int -- | a note on a source file data BWNote BWNote :: BWNoteStatus -> String -> BWLocation -> BWNote -- | status of the note bwn_status :: BWNote -> BWNoteStatus -- | message bwn_title :: BWNote -> String -- | where the note is bwn_location :: BWNote -> BWLocation isBWNoteError :: BWNote -> Bool -- | simple type encapsulating the fact the operations return along with -- notes generated on files type OpResult a = (a, [BWNote]) -- | result: success + files impacted data BuildResult BuildResult :: Bool -> [FilePath] -> BuildResult -- | which cabal file to use operations data WhichCabal -- | use proper file Source :: WhichCabal -- | use temporary file that was saved in temp folder Target :: WhichCabal -- | type of elements for the outline data OutlineDefType Class :: OutlineDefType Data :: OutlineDefType Family :: OutlineDefType Function :: OutlineDefType Pattern :: OutlineDefType Syn :: OutlineDefType Type :: OutlineDefType Instance :: OutlineDefType Field :: OutlineDefType Constructor :: OutlineDefType Splice :: OutlineDefType -- | Location inside a file, the file is known and doesn't need to be -- repeated data InFileLoc InFileLoc :: Int -> Int -> InFileLoc -- | line ifl_line :: InFileLoc -> Int -- | column ifl_column :: InFileLoc -> Int -- | Span inside a file, the file is known and doesn't need to be repeated data InFileSpan InFileSpan :: InFileLoc -> InFileLoc -> InFileSpan -- | start location ifs_start :: InFileSpan -> InFileLoc -- | end location ifs_end :: InFileSpan -> InFileLoc -- | construct a file span mkFileSpan :: Int -> Int -> Int -> Int -> InFileSpan -- | element of the outline result data OutlineDef OutlineDef :: Text -> [OutlineDefType] -> InFileSpan -> [OutlineDef] -> Maybe Text -> Maybe Text -> OutlineDef -- | name od_name :: OutlineDef -> Text -- | types: can have several to combine od_type :: OutlineDef -> [OutlineDefType] -- | span in source od_loc :: OutlineDef -> InFileSpan -- | children (constructors...) od_children :: OutlineDef -> [OutlineDef] -- | type signature if any od_signature :: OutlineDef -> Maybe Text -- | comment if any od_comment :: OutlineDef -> Maybe Text -- | constructs an OutlineDef with no children and no type signature mkOutlineDef :: Text -> [OutlineDefType] -> InFileSpan -> OutlineDef -- | constructs an OutlineDef with children and no type signature mkOutlineDefWithChildren :: Text -> [OutlineDefType] -> InFileSpan -> [OutlineDef] -> OutlineDef -- | Lexer token data TokenDef TokenDef :: Text -> InFileSpan -> TokenDef -- | type of token td_name :: TokenDef -> Text -- | location td_loc :: TokenDef -> InFileSpan -- | Type of import/export directive data ImportExportType -- | Var IEVar :: ImportExportType -- | Abs IEAbs :: ImportExportType -- | import/export everythin IEThingAll :: ImportExportType -- | specific import/export list IEThingWith :: ImportExportType -- | reexport module IEModule :: ImportExportType -- | definition of export data ExportDef ExportDef :: Text -> ImportExportType -> InFileSpan -> [Text] -> ExportDef -- | name e_name :: ExportDef -> Text -- | type e_type :: ExportDef -> ImportExportType -- | location in source file e_loc :: ExportDef -> InFileSpan -- | children (constructor names, etc.) e_children :: ExportDef -> [Text] -- | definition of an import element data ImportSpecDef ImportSpecDef :: Text -> ImportExportType -> InFileSpan -> [Text] -> ImportSpecDef -- | name is_name :: ImportSpecDef -> Text -- | type is_type :: ImportSpecDef -> ImportExportType -- | location in source file is_loc :: ImportSpecDef -> InFileSpan -- | children (constructor names, etc.) is_children :: ImportSpecDef -> [Text] -- | definition of an import statement data ImportDef ImportDef :: Text -> InFileSpan -> Bool -> Bool -> Text -> Maybe [ImportSpecDef] -> ImportDef -- | module name i_module :: ImportDef -> Text -- | location in source file i_loc :: ImportDef -> InFileSpan -- | is the import qualified i_qualified :: ImportDef -> Bool -- | is the import element list for hiding or exposing i_hiding :: ImportDef -> Bool -- | alias name i_alias :: ImportDef -> Text -- | specific import elements i_children :: ImportDef -> Maybe [ImportSpecDef] -- | complete result for outline data OutlineResult OutlineResult :: [OutlineDef] -> [ExportDef] -> [ImportDef] -> OutlineResult -- | outline contents or_outline :: OutlineResult -> [OutlineDef] -- | exports or_exports :: OutlineResult -> [ExportDef] -- | imports or_imports :: OutlineResult -> [ImportDef] -- | build flags for a specific file data BuildFlags BuildFlags :: [String] -> [String] -> Maybe String -> BuildFlags -- | flags for GHC bf_ast :: BuildFlags -> [String] -- | flags for preprocessor bf_preproc :: BuildFlags -> [String] -- | module name if known bf_modName :: BuildFlags -> Maybe String data ThingAtPoint ThingAtPoint :: String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> ThingAtPoint tapName :: ThingAtPoint -> String tapModule :: ThingAtPoint -> Maybe String tapType :: ThingAtPoint -> Maybe String tapQType :: ThingAtPoint -> Maybe String tapHType :: ThingAtPoint -> Maybe String tapGType :: ThingAtPoint -> Maybe String -- | get the full path for the temporary directory getFullTempDir :: BuildWrapper FilePath -- | get the full path for the temporary dist directory (where cabal will -- write its output) getDistDir :: BuildWrapper FilePath -- | get full path in temporary folder for source file (i.e. where we're -- going to write the temporary contents of an edited file) getTargetPath :: FilePath -> BuildWrapper FilePath -- | get the full, canonicalized path of a source canonicalizeFullPath :: FilePath -> BuildWrapper FilePath -- | get the full path of a source getFullSrc :: FilePath -> BuildWrapper FilePath -- | copy a file from the normal folders to the temp folder copyFromMain :: Bool -> FilePath -> BuildWrapper (Maybe FilePath) -- | replace relative file path by module name fileToModule :: FilePath -> String -- | Verbosity settings data Verbosity Silent :: Verbosity Normal :: Verbosity Verbose :: Verbosity Deafening :: Verbosity -- | component in cabal file data CabalComponent -- | library CCLibrary :: Bool -> CabalComponent -- | is the test suite buildable -- -- is the executable buildable -- -- is the library buildable cc_buildable :: CabalComponent -> Bool -- | executable CCExecutable :: String -> Bool -> CabalComponent -- | executable name cc_exe_name :: CabalComponent -> String -- | is the test suite buildable -- -- is the executable buildable -- -- is the library buildable cc_buildable :: CabalComponent -> Bool -- | test suite CCTestSuite :: String -> Bool -> CabalComponent -- | test suite name cc_test_name :: CabalComponent -> String -- | is the test suite buildable -- -- is the executable buildable -- -- is the library buildable cc_buildable :: CabalComponent -> Bool -- | a cabal package data CabalPackage CabalPackage :: String -> String -> Bool -> [CabalComponent] -> [String] -> CabalPackage -- | name of package cp_name :: CabalPackage -> String -- | version cp_version :: CabalPackage -> String -- | is the package exposed or hidden cp_exposed :: CabalPackage -> Bool -- | components in the cabal file that use this package cp_dependent :: CabalPackage -> [CabalComponent] -- | all modules. We keep all modules so that we can try to open non -- exposed but imported modules directly cp_modules :: CabalPackage -> [String] -- | -- http:book.realworldhaskell.orgreadio-case-study-a-library-for-searching-the-filesystem.html getRecursiveContents :: FilePath -> IO [FilePath] -- | debug method: fromJust with a message to display when we get Nothing fromJustDebug :: String -> Maybe a -> a -- | remove a base directory from a string representing a full path removeBaseDir :: FilePath -> String -> String instance Typeable WhichCabal instance Typeable BuildFlags instance Typeable ThingAtPoint instance Typeable Verbosity instance Show BWNoteStatus instance Read BWNoteStatus instance Eq BWNoteStatus instance Show BWLocation instance Read BWLocation instance Eq BWLocation instance Show BWNote instance Read BWNote instance Eq BWNote instance Show BuildResult instance Read BuildResult instance Eq BuildResult instance Show WhichCabal instance Read WhichCabal instance Eq WhichCabal instance Enum WhichCabal instance Data WhichCabal instance Show OutlineDefType instance Read OutlineDefType instance Eq OutlineDefType instance Ord OutlineDefType instance Enum OutlineDefType instance Show InFileLoc instance Read InFileLoc instance Eq InFileLoc instance Ord InFileLoc instance Show InFileSpan instance Read InFileSpan instance Eq InFileSpan instance Ord InFileSpan instance Show OutlineDef instance Read OutlineDef instance Eq OutlineDef instance Ord OutlineDef instance Show TokenDef instance Eq TokenDef instance Show ImportExportType instance Read ImportExportType instance Eq ImportExportType instance Ord ImportExportType instance Enum ImportExportType instance Show ExportDef instance Eq ExportDef instance Show ImportSpecDef instance Eq ImportSpecDef instance Show ImportDef instance Eq ImportDef instance Show OutlineResult instance Eq OutlineResult instance Show BuildFlags instance Read BuildFlags instance Eq BuildFlags instance Data BuildFlags instance Show ThingAtPoint instance Read ThingAtPoint instance Eq ThingAtPoint instance Data ThingAtPoint instance Show Verbosity instance Read Verbosity instance Eq Verbosity instance Ord Verbosity instance Enum Verbosity instance Bounded Verbosity instance Data Verbosity instance Eq CabalComponent instance Show CabalComponent instance Eq CabalPackage instance Show CabalPackage instance FromJSON CabalPackage instance ToJSON CabalPackage instance FromJSON CabalComponent instance ToJSON CabalComponent instance FromJSON ThingAtPoint instance ToJSON ThingAtPoint instance FromJSON BuildFlags instance ToJSON BuildFlags instance FromJSON OutlineResult instance ToJSON OutlineResult instance FromJSON ImportDef instance ToJSON ImportDef instance FromJSON ImportSpecDef instance ToJSON ImportSpecDef instance FromJSON ExportDef instance ToJSON ExportDef instance FromJSON ImportExportType instance ToJSON ImportExportType instance FromJSON TokenDef instance ToJSON TokenDef instance FromJSON OutlineDef instance ToJSON OutlineDef instance FromJSON InFileSpan instance ToJSON InFileSpan instance FromJSON OutlineDefType instance ToJSON OutlineDefType instance FromJSON BuildResult instance ToJSON BuildResult instance FromJSON BWNote instance ToJSON BWNote instance FromJSON BWLocation instance ToJSON BWLocation instance FromJSON BWNoteStatus instance ToJSON BWNoteStatus module Language.Haskell.BuildWrapper.Cabal getFilesToCopy :: BuildWrapper (OpResult [FilePath]) cabalV :: BuildWrapper Verbosity -- | run cabal build cabalBuild :: Bool -> WhichCabal -> BuildWrapper (OpResult BuildResult) -- | run cabal build cabalBuild' :: Bool -> Bool -> WhichCabal -> BuildWrapper (OpResult BuildResult) -- | run cabal configure cabalConfigure :: WhichCabal -> BuildWrapper (OpResult (Maybe LocalBuildInfo)) -- | get the full path to the cabal file getCabalFile :: WhichCabal -> BuildWrapper FilePath -- | get Cabal build info, running configure if needed cabalInit :: WhichCabal -> BuildWrapper (OpResult (Maybe LocalBuildInfo)) -- | run a action with the cabal build info withCabal :: WhichCabal -> (LocalBuildInfo -> BuildWrapper a) -> BuildWrapper (OpResult (Maybe a)) -- | parse cabal error messages and transform them in notre parseCabalMessages :: FilePath -> FilePath -> String -> [BWNote] setupExe :: FilePath -> FilePath dropPrefixes :: [String] -> String -> Maybe String stripPrefixIfNeeded :: String -> String -> Maybe String -> Maybe String addCurrent :: Maybe (BWNote, [String]) -> [BWNote] -> [BWNote] cabalErrorLine :: FilePath -> FilePath -> String -> Maybe (BWNote, [String]) -- | parse messages from build parseBuildMessages :: FilePath -> FilePath -> FilePath -> String -> [BWNote] validLoc :: FilePath -> FilePath -> FilePath -> FilePath readInt :: String -> Int -> Int -- | add a message to the note makeNote :: BWNote -> [String] -> BWNote -- | get the path of a file getting compiled getBuiltPath :: String -> Maybe FilePath -- | the cabal build info for a specific component data CabalBuildInfo CabalBuildInfo :: BuildInfo -> ComponentLocalBuildInfo -> FilePath -> Bool -> [(ModuleName, FilePath)] -> CabalBuildInfo -- | the build info cbiBuildInfo :: CabalBuildInfo -> BuildInfo -- | the component local build info cbiComponentBuildInfo :: CabalBuildInfo -> ComponentLocalBuildInfo -- | the folder to build that component into cbiBuildFolder :: CabalBuildInfo -> FilePath -- | is the component the library cbiIsLibrary :: CabalBuildInfo -> Bool -- | the module name and corresponding source file for each contained -- Haskell module cbiModulePaths :: CabalBuildInfo -> [(ModuleName, FilePath)] -- | canonicalize the paths in the build info canonicalizeBuildInfo :: CabalBuildInfo -> BuildWrapper CabalBuildInfo -- | apply a function on the build info modules and paths, in a monad onModulePathsM :: Monad a => ([(ModuleName, FilePath)] -> a [(ModuleName, FilePath)]) -> CabalBuildInfo -> a CabalBuildInfo -- | apply a function on the build info modules and paths onModulePaths :: ([(ModuleName, FilePath)] -> [(ModuleName, FilePath)]) -> CabalBuildInfo -> CabalBuildInfo -- | get the build info for a given source file if a source file is in -- several component, get the first one getBuildInfo :: FilePath -> BuildWrapper (OpResult (Maybe (LocalBuildInfo, CabalBuildInfo))) -- | get GHC options for a file fileGhcOptions :: (LocalBuildInfo, CabalBuildInfo) -> BuildWrapper (ModuleName, [String]) -- | get CPP options for a file fileCppOptions :: CabalBuildInfo -> [String] -- | get the cabal extensions cabalExtensions :: CabalBuildInfo -> (ModuleName, [String]) -- | get the source directory from a build info getSourceDirs :: BuildInfo -> [FilePath] -- | get all components, referencing all the files found in the source -- folders getAllFiles :: LocalBuildInfo -> BuildWrapper [CabalBuildInfo] -- | get all components, referencing only the files explicitely indicated -- in the cabal file getReferencedFiles :: LocalBuildInfo -> BuildWrapper [CabalBuildInfo] -- | convert a ModuleName to a String moduleToString :: ModuleName -> String -- | get all components in the Cabal file cabalComponents :: BuildWrapper (OpResult [CabalComponent]) -- | get all the dependencies in the cabal file cabalDependencies :: BuildWrapper (OpResult [(FilePath, [CabalPackage])]) -- | get all dependencies from the package description and the list of -- installed packages dependencies :: PackageDescription -> [(FilePath, [InstalledPackageInfo])] -> [(FilePath, [CabalPackage])] -- | get all components from the package description cabalComponentsFromDescription :: PackageDescription -> [CabalComponent] module Language.Haskell.BuildWrapper.GHC -- | get the GHC typechecked AST getAST :: FilePath -> FilePath -> String -> [String] -> IO (OpResult (Maybe TypecheckedSource)) -- | perform an action on the GHC Typechecked module withAST :: (TypecheckedModule -> Ghc a) -> FilePath -> FilePath -> String -> [String] -> IO (Maybe a) -- | perform an action on the GHC JSON AST withJSONAST :: (Value -> IO a) -> FilePath -> FilePath -> String -> [String] -> IO (Maybe a) -- | the main method loading the source contents into GHC withASTNotes :: (TypecheckedModule -> Ghc a) -> FilePath -> FilePath -> String -> [String] -> IO (OpResult (Maybe a)) -- | Convert Messages to '[BWNote]'. -- -- This will mix warnings and errors, but you can split them back up by -- filtering the '[BWNote]' based on the bw_status. ghcMessagesToNotes :: FilePath -> Messages -> [BWNote] -- | get all names in scope getGhcNamesInScope :: FilePath -> FilePath -> String -> [String] -> IO [String] -- | get the thing at a particular point (line/column) in the source -- this is using the saved JSON info if available getThingAtPointJSON :: Int -> Int -> FilePath -> FilePath -> String -> [String] -> IO (Maybe ThingAtPoint) -- | convert a GHC SrcSpan to a Span, ignoring the actual file info ghcSpanToLocation :: SrcSpan -> InFileSpan -- | convert a GHC SrcSpan to a BWLocation ghcSpanToBWLocation :: FilePath -> SrcSpan -> BWLocation -- | convert a column info from GHC to our system (1 based) ghcColToScionCol :: Int -> Int -- | convert a column info from our system (1 based) to GHC scionColToGhcCol :: Int -> Int -- | Get a stream of tokens generated by the GHC lexer from the current -- document ghctokensArbitrary :: FilePath -> String -> [String] -> IO (Either BWNote [Located Token]) lexLoc :: RealSrcLoc lexerFlags :: [ExtensionFlag] -- | Filter tokens whose span appears legitimate (start line is less than -- end line, start column is less than end column.) ofInterest :: Located Token -> Bool -- | Convert a GHC token to an interactive token (abbreviated token type) tokenToType :: Located Token -> TokenDef -- | Generate the interactive token list used by EclipseFP for syntax -- highlighting tokenTypesArbitrary :: FilePath -> String -> Bool -> [String] -> IO (Either BWNote [TokenDef]) -- | Extract occurrences based on lexing occurrences :: FilePath -> String -> Text -> Bool -> [String] -> IO (Either BWNote [TokenDef]) -- | Parse the current document, generating a TokenDef list, filtered by a -- function generateTokens :: FilePath -> String -> Bool -> [String] -> ([Located Token] -> [TokenDef]) -> ([TokenDef] -> a) -> IO (Either BWNote a) -- | Preprocess some source, returning the literate and Haskell source as -- tuple. preprocessSource :: String -> Bool -> ([TokenDef], String) data PPBehavior Continue :: Int -> PPBehavior Indent :: Int -> PPBehavior Start :: PPBehavior -- | convert a GHC error message to our note type ghcErrMsgToNote :: FilePath -> ErrMsg -> BWNote -- | convert a GHC warning message to our note type ghcWarnMsgToNote :: FilePath -> WarnMsg -> BWNote ghcMsgToNote :: BWNoteStatus -> FilePath -> ErrMsg -> BWNote -- | remove the initial status text from a message removeStatus :: BWNoteStatus -> String -> String -- | make unqualified token mkUnqualTokenValue :: FastString -> Text -- | make qualified token: join the qualifier and the name by a dot mkQualifiedTokenValue :: FastString -> FastString -> Text -- | Make a token definition from its source location and Lexer.hs token -- type. mkTokenDef :: Located Token -> TokenDef mkTokenDef (L sp t) = -- TokenDef (mkTokenName t) (ghcSpanToLocation sp) mkTokenName :: Token -> Text tokenType :: Token -> Text dotFS :: FastString tokenValue :: Bool -> Token -> Text start, end :: SrcSpan -> (Int, Int) instance Data Token instance Typeable Token instance Eq PPBehavior instance Monoid (Bag a) module Language.Haskell.BuildWrapper.API -- | copy all files from the project to the temporary folder synchronize :: Bool -> BuildWrapper (OpResult [FilePath]) -- | synchronize one file only synchronize1 :: Bool -> FilePath -> BuildWrapper (Maybe FilePath) -- | write contents to temporary file write :: FilePath -> String -> BuildWrapper () -- | run cabal configure configure :: WhichCabal -> BuildWrapper (OpResult Bool) -- | run cabal build build :: Bool -> WhichCabal -> BuildWrapper (OpResult BuildResult) -- | build one source file in GHC build1 :: FilePath -> BuildWrapper (OpResult Bool) -- | preprocess a file preproc :: BuildFlags -> FilePath -> IO String -- | get the build flags for a source file getBuildFlags :: FilePath -> BuildWrapper (OpResult BuildFlags) -- | get haskell-src-exts commented AST for source file getAST :: FilePath -> BuildWrapper (OpResult (Maybe (ParseResult (Module SrcSpanInfo, [Comment])))) -- | get GHC typechecked AST for source file getGHCAST :: FilePath -> BuildWrapper (OpResult (Maybe TypecheckedSource)) -- | perform an action on the GHC AST withGHCAST :: FilePath -> (FilePath -> FilePath -> String -> [String] -> IO a) -> BuildWrapper (OpResult (Maybe a)) withGHCAST' :: FilePath -> ([BWNote] -> FilePath -> FilePath -> String -> [String] -> IO (OpResult (Maybe a))) -> BuildWrapper (OpResult (Maybe a)) -- | get outline for source file getOutline :: FilePath -> BuildWrapper (OpResult OutlineResult) -- | get all occurrences of a token in the file -- -- get lexer token types for source file getTokenTypes :: FilePath -> BuildWrapper (OpResult [TokenDef]) getOccurrences :: FilePath -> String -> BuildWrapper (OpResult [TokenDef]) -- | get thing at point getThingAtPoint :: FilePath -> Int -> Int -> BuildWrapper (OpResult (Maybe ThingAtPoint)) -- | get all names in scope (GHC API) getNamesInScope :: FilePath -> BuildWrapper (OpResult (Maybe [String])) -- | get cabal dependencies getCabalDependencies :: BuildWrapper (OpResult [(FilePath, [CabalPackage])]) -- | get cabal components getCabalComponents :: BuildWrapper (OpResult [CabalComponent])