Copyright | (c) JP Moresmau 2011 |
---|---|
License | BSD3 |
Maintainer | jpmoresmau@gmail.com |
Stability | beta |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Data types, State Monad, utility functions
- type BuildWrapper = StateT BuildWrapperState IO
- data BuildWrapperState = BuildWrapperState {
- tempFolder :: String
- cabalPath :: FilePath
- cabalFile :: FilePath
- verbosity :: Verbosity
- cabalFlags :: String
- cabalOpts :: [String]
- logCabalArgs :: Bool
- data BWNoteStatus
- readObj :: Read a => String -> String -> a
- data BWLocation = BWLocation {}
- mkEmptySpan :: FilePath -> Int -> Int -> BWLocation
- data BWNote = BWNote {}
- isBWNoteError :: BWNote -> Bool
- type OpResult a = (a, [BWNote])
- data BuildResult = BuildResult Bool [FilePath]
- data WhichCabal
- data OutlineDefType
- data InFileLoc = InFileLoc {}
- data InFileSpan = InFileSpan {}
- ifsOverlap :: InFileSpan -> InFileSpan -> Bool
- iflOverlap :: InFileSpan -> InFileLoc -> Bool
- mkFileSpan :: Int -> Int -> Int -> Int -> InFileSpan
- data NameDef = NameDef {
- ndName :: Text
- ndType :: [OutlineDefType]
- ndSignature :: Maybe Text
- data OutlineDef = OutlineDef {
- odName :: Text
- odType :: [OutlineDefType]
- odLoc :: InFileSpan
- odChildren :: [OutlineDef]
- odSignature :: Maybe Text
- odComment :: Maybe Text
- odStartLineComment :: Maybe Int
- mkOutlineDef :: Text -> [OutlineDefType] -> InFileSpan -> OutlineDef
- mkOutlineDefWithChildren :: Text -> [OutlineDefType] -> InFileSpan -> [OutlineDef] -> OutlineDef
- data TokenDef = TokenDef {
- tdName :: Text
- tdLoc :: InFileSpan
- data ImportExportType
- = IEVar
- | IEAbs
- | IEThingAll
- | IEThingWith
- | IEModule
- data ExportDef = ExportDef {
- eName :: Text
- eType :: ImportExportType
- eLoc :: InFileSpan
- eChildren :: [Text]
- data ImportSpecDef = ImportSpecDef {
- isName :: Text
- isType :: ImportExportType
- isLoc :: InFileSpan
- isChildren :: [Text]
- data ImportDef = ImportDef {}
- data OutlineResult = OutlineResult {}
- data BuildFlags = BuildFlags {}
- data ThingAtPoint = ThingAtPoint {}
- getFullTempDir :: BuildWrapper FilePath
- getDistDir :: BuildWrapper FilePath
- getTargetPath :: FilePath -> BuildWrapper FilePath
- getTargetPath' :: FilePath -> FilePath -> IO FilePath
- canonicalizeFullPath :: FilePath -> BuildWrapper FilePath
- getFullSrc :: FilePath -> BuildWrapper FilePath
- copyFromMain :: Bool -> FilePath -> BuildWrapper (Maybe FilePath)
- isSourceMoreRecent :: FilePath -> FilePath -> IO Bool
- fileToModule :: FilePath -> String
- data Verbosity
- data CabalComponent
- = CCLibrary {
- ccBuildable :: Bool
- | CCExecutable {
- ccExeName :: String
- ccBuildable :: Bool
- | CCTestSuite {
- ccTestName :: String
- ccBuildable :: Bool
- | CCBenchmark {
- ccBenchName :: String
- ccBuildable :: Bool
- = CCLibrary {
- cabalComponentName :: CabalComponent -> String
- data CabalPackage = CabalPackage {
- cpName :: String
- cpVersion :: String
- cpExposed :: Bool
- cpDependent :: [CabalComponent]
- cpModules :: [String]
- data ImportClean = ImportClean {
- icSpan :: InFileSpan
- icText :: Text
- data LoadContents
- = SingleFile { }
- | MultipleFile { }
- getLoadFiles :: LoadContents -> [(FilePath, String)]
- getRecursiveContents :: FilePath -> IO [FilePath]
- getRecursiveContentsHidden :: FilePath -> IO [FilePath]
- deleteGhosts :: [FilePath] -> BuildWrapper [FilePath]
- deleteTemp :: BuildWrapper ()
- deleteGenerated :: BuildWrapper ()
- fromJustDebug :: String -> Maybe a -> a
- removeBaseDir :: FilePath -> String -> String
- nubOrd :: Ord a => [a] -> [a]
- formatJSON :: String -> String
- data Usage = Usage {}
- readFile :: FilePath -> IO String
- writeFile :: FilePath -> String -> IO ()
- withBinaryFile :: FilePath -> IOMode -> (Handle -> IO a) -> IO a
- data EvalResult = EvalResult {}
- splitString :: Eq a => [a] -> [a] -> ([a], [a])
- runAndPrint :: FilePath -> [String] -> IO (ExitCode, String, String)
Documentation
type BuildWrapper = StateT BuildWrapperState IO Source
State type
data BuildWrapperState Source
the state we keep
BuildWrapperState | |
|
data BWNoteStatus Source
status of notes: error or warning
readObj :: Read a => String -> String -> a Source
read an object from a String, with a given error message if it fails
mkEmptySpan :: FilePath -> Int -> Int -> BWLocation Source
build an empty span in a given file at a given location
a note on a source file
BWNote | |
|
isBWNoteError :: BWNote -> Bool Source
is a note an error?
type OpResult a = (a, [BWNote]) Source
simple type encapsulating the fact the operations return along with notes generated on files
data BuildResult Source
result: success + files impacted
data WhichCabal Source
result for building one file: success + names data Build1Result=Build1Result Bool [NameDef] deriving (Show,Read,Eq)
instance ToJSON Build1Result where toJSON (Build1Result b ns)= object ["r" .= b, "ns" .= map toJSON ns]
instance FromJSON Build1Result where parseJSON (Object v) =Build1Result $ v .: "r" * v .: "ns" parseJSON _= mzero
which cabal file to use operations
data OutlineDefType Source
type of elements for the outline
Location inside a file, the file is known and doesn't need to be repeated
data InFileSpan Source
Span inside a file, the file is known and doesn't need to be repeated
ifsOverlap :: InFileSpan -> InFileSpan -> Bool Source
do spans overlap?
iflOverlap :: InFileSpan -> InFileLoc -> Bool Source
does span overlap location?
:: Int | start line |
-> Int | start column |
-> Int | end line |
-> Int | end column |
-> InFileSpan |
construct a file span
definition of a name
NameDef | |
|
data OutlineDef Source
element of the outline result
OutlineDef | |
|
:: Text | name |
-> [OutlineDefType] | types: can have several to combine |
-> InFileSpan | span in source |
-> OutlineDef |
constructs an OutlineDef with no children and no type signature
mkOutlineDefWithChildren Source
:: Text | name |
-> [OutlineDefType] | types: can have several to combine |
-> InFileSpan | span in source |
-> [OutlineDef] | children (constructors...) |
-> OutlineDef |
constructs an OutlineDef with children and no type signature
Lexer token
TokenDef | |
|
data ImportExportType Source
Type of import/export directive
IEVar | Var |
IEAbs | Abs |
IEThingAll | import/export everything |
IEThingWith | specific import/export list |
IEModule | reexport module |
definition of export
ExportDef | |
|
data ImportSpecDef Source
definition of an import element
ImportSpecDef | |
|
definition of an import statement
getFullTempDir :: BuildWrapper FilePath Source
get the full path for the temporary directory
getDistDir :: BuildWrapper FilePath Source
get the full path for the temporary dist directory (where cabal will write its output)
:: FilePath | relative path of source file |
-> 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)
get full path in temporary folder for source file (i.e. where we're going to write the temporary contents of an edited file)
:: FilePath | relative path of source file |
-> BuildWrapper FilePath |
get the full, canonicalized path of a source
:: FilePath | relative path of source file |
-> BuildWrapper FilePath |
get the full path of a source
:: Bool | copy even if temp file is newer |
-> FilePath | relative path of source file |
-> BuildWrapper (Maybe FilePath) | return Just the file if copied, Nothing if no copy was done |
copy a file from the normal folders to the temp folder
isSourceMoreRecent :: FilePath -> FilePath -> IO Bool Source
is the source file more recent than the target file?
fileToModule :: FilePath -> String Source
replace relative file path by module name
Verbosity settings
data CabalComponent Source
component in cabal file
CCLibrary | library |
| |
CCExecutable | executable |
| |
CCTestSuite | test suite |
| |
CCBenchmark | test suite |
|
cabalComponentName :: CabalComponent -> String Source
get the cabal component name
data CabalPackage Source
a cabal package
CabalPackage | |
|
data ImportClean Source
import clean operation: the span of text to change, the new text
ImportClean | |
|
data LoadContents Source
information about files to load (single file or multiple files)
getLoadFiles :: LoadContents -> [(FilePath, String)] Source
get files to load
getRecursiveContents :: FilePath -> IO [FilePath] Source
deleteGhosts :: [FilePath] -> BuildWrapper [FilePath] Source
delete files in temp folder but not in real folder anymore
deleteTemp :: BuildWrapper () Source
delete all temporary files
deleteGenerated :: BuildWrapper () Source
delete generated files
fromJustDebug :: String -> Maybe a -> a Source
debug method: fromJust with a message to display when we get Nothing
removeBaseDir :: FilePath -> String -> String Source
remove a base directory from a string representing a full path
formatJSON :: String -> String Source
debug method to vaguely format JSON result to dump them
Usage structure
readFile :: FilePath -> IO String Source
read a string from a file, forcing the read and closing the handle
withBinaryFile :: FilePath -> IOMode -> (Handle -> IO a) -> IO a Source
perform operation on a binary opened file
data EvalResult Source
Evaluation of result using String since we get them from GHC API this can be fully evaluated via deepseq to make sure any side effect are evaluated
splitString :: Eq a => [a] -> [a] -> ([a], [a]) Source
splits a string at the first occurence of prefix