ihaskell-0.10.3.0: A Haskell backend kernel for the Jupyter project.
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

Pragma PragmaType [String]

A list of GHC pragmas (from a {-# LANGUAGE ... #-} block)

Instances

Instances details
Show CodeBlock Source # 
Instance details

Defined in IHaskell.Eval.Parser

Eq CodeBlock Source # 
Instance details

Defined in IHaskell.Eval.Parser

data StringLoc #

A location in an input string.

Instances

Instances details
Show StringLoc 
Instance details

Defined in Language.Haskell.GHC.Parser

Eq StringLoc 
Instance details

Defined in Language.Haskell.GHC.Parser

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

GetKindBang

Get the kind and normalised type via ':kind!'.

LoadModule

Load and unload modules via ':module'.

SPrint

Print without evaluating via ':sprint'.

Reload

Reload.

Instances

Instances details
Show DirectiveType Source # 
Instance details

Defined in IHaskell.Eval.Parser

Eq DirectiveType Source # 
Instance details

Defined in IHaskell.Eval.Parser

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.

Quasiquotes are allowed via a post-processing step.

parseDirective Source #

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 by piece.

data Located a #

Store locations along with a value.

Constructors

Located 

Fields

Instances

Instances details
Functor Located 
Instance details

Defined in Language.Haskell.GHC.Parser

Methods

fmap :: (a -> b) -> Located a -> Located b #

(<$) :: a -> Located b -> Located a #

Show a => Show (Located a) 
Instance details

Defined in Language.Haskell.GHC.Parser

Methods

showsPrec :: Int -> Located a -> ShowS #

show :: Located a -> String #

showList :: [Located a] -> ShowS #

Eq a => Eq (Located a) 
Instance details

Defined in Language.Haskell.GHC.Parser

Methods

(==) :: Located a -> Located a -> Bool #

(/=) :: Located a -> Located a -> Bool #

data PragmaType Source #

Pragma types. Only LANGUAGE pragmas are currently supported. Other pragma types are kept around as a string for error reporting.

Instances

Instances details
Show PragmaType Source # 
Instance details

Defined in IHaskell.Eval.Parser

Eq PragmaType Source # 
Instance details

Defined in IHaskell.Eval.Parser