Safe Haskell | None |
---|
- parseString :: String -> Ghc [Located CodeBlock]
- data CodeBlock
- data StringLoc = Loc LineNumber ColumnNumber
- data DirectiveType
- = GetType
- | GetInfo
- | SetDynFlag
- | LoadFile
- | SetOption
- | SetExtension
- | ShellCmd
- | GetHelp
- | SearchHoogle
- | GetDoc
- | GetKind
- type LineNumber = Int
- type ColumnNumber = Int
- type ErrMsg = String
- layoutChunks :: String -> [Located String]
- parseDirective :: String -> Int -> CodeBlock
- getModuleName :: GhcMonad m => String -> m [String]
- data Located a = Located {
- line :: LineNumber
- unloc :: a
Documentation
parseString :: String -> Ghc [Located CodeBlock]Source
Parse a string into code blocks.
A block of code to be evaluated. Each block contains a single element - one declaration, statement, expression, etc. If parsing of the block failed, the block is instead a ParseError, which has the error location and error message.
Expression String | A Haskell expression. |
Declaration String | A data type or function declaration. |
Statement String | A Haskell statement (as if in a `do` block). |
Import String | An import statement. |
TypeSignature String | A lonely type signature (not above a function declaration). |
Directive DirectiveType String | An IHaskell directive. |
Module String | A full Haskell module, to be compiled and loaded. |
ParseError StringLoc ErrMsg | An error indicating that parsing the code block failed. |
data StringLoc
A location in an input string.
data DirectiveType Source
Directive types. Each directive is associated with a string in the directive code block.
GetType | Get the type of an expression via ':type' (or unique prefixes) |
GetInfo | Get info about the identifier via ':info' (or unique prefixes) |
SetDynFlag | Enable or disable an extensions, packages etc. via `:set`. Emulates GHCi's `:set` |
LoadFile | Load a Haskell module. |
SetOption | Set IHaskell kernel option `:option`. |
SetExtension | `:extension Foo` is a shortcut for `:set -XFoo` |
ShellCmd | Execute a shell command. |
GetHelp | General help via |
SearchHoogle | Search for something via Hoogle. |
GetDoc | Get documentation for an identifier via Hoogle. |
GetKind | Get the kind of a type via ':kind'. |
type LineNumber = Int
A line number in an input string.
type ColumnNumber = Int
A column number in an input string.
layoutChunks :: String -> [Located String]
Split an input string into chunks based on indentation. A chunk is a line and all lines immediately following that are indented beyond the indentation of the first line. This parses Haskell layout rules properly, and allows using multiline expressions via indentation.
:: String | Directive string. |
-> Int | Line number at which the directive appears. |
-> CodeBlock | Directive code block or a parse error. |
Parse a directive of the form :directiveName.
getModuleName :: GhcMonad m => String -> m [String]Source
Parse a module and return the name declared in the 'module X where' line. That line is required, and if it does not exist, this will error. Names with periods in them are returned piece y piece.