ihaskell-0.4.3.0: A Haskell backend kernel for the IPython project.

Safe HaskellNone

IHaskell.Eval.Parser

Synopsis

Documentation

parseString :: String -> Ghc [Located CodeBlock]Source

Parse a string into code blocks.

data CodeBlock Source

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.

Constructors

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.

Constructors

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 :? or ':help'.

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.

type ErrMsg = String

An error message 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.

parseDirectiveSource

Arguments

:: 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.

data Located a

Store locations along with a value.

Constructors

Located 

Fields

line :: LineNumber
 
unloc :: a
 

Instances

Functor Located 
Eq a => Eq (Located a) 
Show a => Show (Located a)