haskell-src-exts-1.23.1: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer

Copyright | (c) Niklas Broberg 2004-2009 (c) Michael Sloan 2013
License | BSD-style (see the file LICENSE.txt)
Maintainer | Niklas Broberg, d00nibro@chalmers.se
Stability | stable
Portability | portable
Safe Haskell | None
Language | Haskell98

Language.Haskell.Exts.Parser

Contents

- General parsing
- Parsing of specific AST elements
  - Modules
  - Expressions
  - Statements
  - Patterns
  - Declarations
  - Types
  - Imports
- Non-greedy parsers
  - Module head parsers
- Orphan instances

Description

Annotated parser for Haskell with extensions.

Synopsis

- class Parseable ast where
  - parse :: String -> ParseResult ast
  - parseWithMode :: ParseMode -> String -> ParseResult ast
  - parseWithComments :: ParseMode -> String -> ParseResult (ast, [Comment])
- data ParseMode = ParseMode {
  - parseFilename :: String
  - baseLanguage :: Language
  - extensions :: [Extension]
  - ignoreLanguagePragmas :: Bool
  - ignoreLinePragmas :: Bool
  - fixities :: Maybe [Fixity]
  - ignoreFunctionArity :: Bool
  }
- defaultParseMode :: ParseMode
- data ParseResult a
  - = ParseOk a
  - | ParseFailed SrcLoc String
- fromParseResult :: ParseResult a -> a
- parseModule :: String -> ParseResult (Module SrcSpanInfo)
- parseModuleWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo)
- parseModuleWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment])
- parseExp :: String -> ParseResult (Exp SrcSpanInfo)
- parseExpWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo)
- parseExpWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment])
- parseStmt :: String -> ParseResult (Stmt SrcSpanInfo)
- parseStmtWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo)
- parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment])
- parsePat :: String -> ParseResult (Pat SrcSpanInfo)
- parsePatWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo)
- parsePatWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment])
- parseDecl :: String -> ParseResult (Decl SrcSpanInfo)
- parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo)
- parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment])
- parseType :: String -> ParseResult (Type SrcSpanInfo)
- parseTypeWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo)
- parseTypeWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment])
- parseImportDecl :: String -> ParseResult (ImportDecl SrcSpanInfo)
- parseImportDeclWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo)
- parseImportDeclWithComments :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment])
- newtype NonGreedy a = NonGreedy {
  - unNonGreedy :: a
  }
- data ListOf a = ListOf SrcSpanInfo [a]
- unListOf :: ListOf a -> [a]
- getTopPragmas :: String -> ParseResult [ModulePragma SrcSpanInfo]
- data PragmasAndModuleName l = PragmasAndModuleName l [ModulePragma l] (Maybe (ModuleName l))
- data PragmasAndModuleHead l = PragmasAndModuleHead l [ModulePragma l] (Maybe (ModuleHead l))
- data ModuleHeadAndImports l = ModuleHeadAndImports l [ModulePragma l] (Maybe (ModuleHead l)) [ImportDecl l]

# General parsing

class Parseable ast where Source #

Class providing function for parsing at many different types.

Note that for convenience of implementation, the default methods have definitions equivalent to `undefined`. The minimal definition is all of the visible methods.

Minimal complete definition

parser

Methods

parse :: String -> ParseResult ast Source #

Parse a string with default mode.

parseWithMode :: ParseMode -> String -> ParseResult ast Source #

Parse a string with an explicit `ParseMode`.

parseWithComments :: ParseMode -> String -> ParseResult (ast, [Comment]) Source #

Parse a string with an explicit `ParseMode`, returning all comments along with the AST.

#### Instances

Instances details

Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))

Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))

Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))

Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))

Parseable (Decl SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Decl SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Decl SrcSpanInfo)
Parseable (Exp SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Exp SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Exp SrcSpanInfo)
Parseable (ImportDecl SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (ImportDecl SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (ImportDecl SrcSpanInfo)
Parseable (Module SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Module SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Module SrcSpanInfo)
Parseable (Pat SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Pat SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Pat SrcSpanInfo)
Parseable (Stmt SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Stmt SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Stmt SrcSpanInfo)
Parseable (Type SrcSpanInfo) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods parse :: String -> ParseResult (Type SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Type SrcSpanInfo)

data ParseMode Source #

Static parameters governing a parse. Note that the various parse functions in Language.Haskell.Exts.Parser never look at LANGUAGE pragmas, regardless of what the `ignoreLanguagePragmas` flag is set to. Only the various `parseFile` functions in Language.Haskell.Exts will act on it, when set to `False`.

Constructors

ParseMode |

Fields

- parseFilename :: String

  original name of the file being parsed

- baseLanguage :: Language

  base language (e.g. Haskell98, Haskell2010)

- extensions :: [Extension]

  list of extensions enabled for parsing

- ignoreLanguagePragmas :: Bool

  if `True`, the parser won't care about further extensions in LANGUAGE pragmas in source files

- ignoreLinePragmas :: Bool

  if `True`, the parser won't read line position information from LINE pragmas in source files

- fixities :: Maybe [Fixity]

  list of fixities to be aware of

- ignoreFunctionArity :: Bool

  Checks whether functions have a consistent arity

defaultParseMode :: ParseMode Source #

Default parameters for a parse. The default is an unknown filename, no extensions (i.e. Haskell 98), don't ignore LANGUAGE pragmas, do ignore LINE pragmas, and be aware of fixities from the `Prelude`.

data ParseResult a Source #

The result of a parse.

Constructors

ParseOk a | The parse succeeded, yielding a value.
ParseFailed SrcLoc String | The parse failed at the specified source location, with an error message.

#### Instances

Instances details

Applicative ParseResult Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods pure :: a -> ParseResult a Source # (<*>) :: ParseResult (a -> b) -> ParseResult a -> ParseResult b Source # liftA2 :: (a -> b -> c) -> ParseResult a -> ParseResult b -> ParseResult c Source # (*>) :: ParseResult a -> ParseResult b -> ParseResult b Source # (<*) :: ParseResult a -> ParseResult b -> ParseResult a Source #
Functor ParseResult Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods fmap :: (a -> b) -> ParseResult a -> ParseResult b Source # (<$) :: a -> ParseResult b -> ParseResult a Source #
Monad ParseResult Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods (>>=) :: ParseResult a -> (a -> ParseResult b) -> ParseResult b Source # (>>) :: ParseResult a -> ParseResult b -> ParseResult b Source # return :: a -> ParseResult a Source #
MonadFail ParseResult Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods fail :: String -> ParseResult a Source #
(Monoid m, Semigroup m) => Monoid (ParseResult m) Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods mempty :: ParseResult m Source # mappend :: ParseResult m -> ParseResult m -> ParseResult m Source # mconcat :: [ParseResult m] -> ParseResult m Source #
Semigroup m => Semigroup (ParseResult m) Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods (<>) :: ParseResult m -> ParseResult m -> ParseResult m Source # sconcat :: NonEmpty (ParseResult m) -> ParseResult m Source # stimes :: Integral b => b -> ParseResult m -> ParseResult m Source #
Show a => Show (ParseResult a) Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods showsPrec :: Int -> ParseResult a -> ShowS Source # show :: ParseResult a -> String Source # showList :: [ParseResult a] -> ShowS Source #
Eq a => Eq (ParseResult a) Source # |
Instance details Defined in Language.Haskell.Exts.ParseMonad Methods (==) :: ParseResult a -> ParseResult a -> Bool Source # (/=) :: ParseResult a -> ParseResult a -> Bool Source #
Ord a => Ord (ParseResult a) Source # |

Instance details

Defined in Language.Haskell.Exts.ParseMonad

Methods

compare :: ParseResult a -> ParseResult a -> Ordering Source #

(<) :: ParseResult a -> ParseResult a -> Bool Source #

(<=) :: ParseResult a -> ParseResult a -> Bool Source #

(>) :: ParseResult a -> ParseResult a -> Bool Source #

(>=) :: ParseResult a -> ParseResult a -> Bool Source #

max :: ParseResult a -> ParseResult a -> ParseResult a Source #

min :: ParseResult a -> ParseResult a -> ParseResult a Source #

fromParseResult :: ParseResult a -> a Source #

Retrieve the result of a successful parse, throwing an error if the parse is actually not successful.

# Parsing of specific AST elements

## Modules

parseModule :: String -> ParseResult (Module SrcSpanInfo) Source #

Parse of a string, which should contain a complete Haskell module, using `defaultParseMode`.

parseModuleWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`.

parseModuleWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Expressions

parseExp :: String -> ParseResult (Exp SrcSpanInfo) Source #

Parse of a string containing a Haskell expression, using `defaultParseMode`.

parseExpWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo) Source #

Parse of a string containing a Haskell expression, using an explicit `ParseMode`.

parseExpWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Statements

parseStmt :: String -> ParseResult (Stmt SrcSpanInfo) Source #

Parse of a string containing a Haskell statement, using `defaultParseMode`.

parseStmtWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo) Source #

Parse of a string containing a Haskell type, using an explicit `ParseMode`.

parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Patterns

parsePat :: String -> ParseResult (Pat SrcSpanInfo) Source #

Parse of a string containing a Haskell pattern, using `defaultParseMode`.

parsePatWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo) Source #

Parse of a string containing a Haskell pattern, using an explicit `ParseMode`.

parsePatWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Declarations

parseDecl :: String -> ParseResult (Decl SrcSpanInfo) Source #

Parse of a string containing a Haskell top-level declaration, using `defaultParseMode`.

parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo) Source #

Parse of a string containing a Haskell top-level declaration, using an explicit `ParseMode`.

parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Types

parseType :: String -> ParseResult (Type SrcSpanInfo) Source #

Parse of a string containing a Haskell type, using `defaultParseMode`.

parseTypeWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo) Source #

Parse of a string containing a Haskell type, using an explicit `ParseMode`.

parseTypeWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

## Imports

parseImportDecl :: String -> ParseResult (ImportDecl SrcSpanInfo) Source #

Parse of a string containing a Haskell statement, using `defaultParseMode`.

parseImportDeclWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo) Source #

Parse of a string containing a Haskell type, using an explicit `ParseMode`.

parseImportDeclWithComments :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment]) Source #

Parse of a string containing a complete Haskell module, using an explicit `ParseMode`, retaining comments.

# Non-greedy parsers

newtype NonGreedy a Source #

Instances of `Parseable` for `NonGreedy a` will only consume the input until `a` is fully parsed. This means that parse errors that come later in the input will be ignored. It's also more efficient, as it's fully lazy in the remainder of the input:

    >>> parse (unlines ("module A where" : "main =" : repeat "blah")) :: ParseResult PragmasAndModuleHead
    ParseOk (NonGreedy {unNonGreedy = PragmasAndModuleHead [] (ModuleName "A",Nothing,Nothing)})

(this example uses the simplified AST)

Constructors

NonGreedy |

Fields

- unNonGreedy :: a

#### Instances

Instances details

Functor NonGreedy Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods fmap :: (a -> b) -> NonGreedy a -> NonGreedy b Source # (<$) :: a -> NonGreedy b -> NonGreedy a Source #
Data a => Data (NonGreedy a) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonGreedy a) Source #

toConstr :: NonGreedy a -> Constr Source #

dataTypeOf :: NonGreedy a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonGreedy a)) Source #

gmapT :: (forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> NonGreedy a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> NonGreedy a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a) Source #

Show a => Show (NonGreedy a) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods showsPrec :: Int -> NonGreedy a -> ShowS Source # show :: NonGreedy a -> String Source # showList :: [NonGreedy a] -> ShowS Source #
Eq a => Eq (NonGreedy a) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods (==) :: NonGreedy a -> NonGreedy a -> Bool Source # (/=) :: NonGreedy a -> NonGreedy a -> Bool Source #
Ord a => Ord (NonGreedy a) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

compare :: NonGreedy a -> NonGreedy a -> Ordering Source #

(<) :: NonGreedy a -> NonGreedy a -> Bool Source #

(<=) :: NonGreedy a -> NonGreedy a -> Bool Source #

(>) :: NonGreedy a -> NonGreedy a -> Bool Source #

(>=) :: NonGreedy a -> NonGreedy a -> Bool Source #

max :: NonGreedy a -> NonGreedy a -> NonGreedy a Source #

min :: NonGreedy a -> NonGreedy a -> NonGreedy a Source #

Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))

Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))

Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))

Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))

data ListOf a Source #

`ListOf a` stores lists of the AST type `a`, along with a `SrcSpanInfo`, in order to provide `Parseable` instances for lists. These instances are provided when the type is used as a list in the syntax, and the same delimiters are used in all of its usages. Some exceptions are made:

Constructors

ListOf SrcSpanInfo [a] |

#### Instances

Instances details

Functor ListOf Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods fmap :: (a -> b) -> ListOf a -> ListOf b Source # (<$) :: a -> ListOf b -> ListOf a Source #
Data a => Data (ListOf a) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListOf a -> c (ListOf a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ListOf a) Source #

toConstr :: ListOf a -> Constr Source #

dataTypeOf :: ListOf a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ListOf a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListOf a)) Source #

gmapT :: (forall b. Data b => b -> b) -> ListOf a -> ListOf a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListOf a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListOf a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ListOf a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ListOf a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a) Source #

Show a => Show (ListOf a) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods showsPrec :: Int -> ListOf a -> ShowS Source # show :: ListOf a -> String Source # showList :: [ListOf a] -> ShowS Source #
Eq a => Eq (ListOf a) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods (==) :: ListOf a -> ListOf a -> Bool Source # (/=) :: ListOf a -> ListOf a -> Bool Source #
Ord a => Ord (ListOf a) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods compare :: ListOf a -> ListOf a -> Ordering Source # (<) :: ListOf a -> ListOf a -> Bool Source # (<=) :: ListOf a -> ListOf a -> Bool Source # (>) :: ListOf a -> ListOf a -> Bool Source # (>=) :: ListOf a -> ListOf a -> Bool Source # max :: ListOf a -> ListOf a -> ListOf a Source # min :: ListOf a -> ListOf a -> ListOf a Source #
Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))

unListOf :: ListOf a -> [a] Source #

## Module head parsers

getTopPragmas :: String -> ParseResult [ModulePragma SrcSpanInfo] Source #

Non-greedy parse of a string starting with a series of top-level option pragmas.

data PragmasAndModuleName l Source #

Type intended to be used with `Parseable`, with instances that implement a non-greedy parse of the module name, including top-level pragmas. This means that a parse error that comes after the module header won't be returned. If the `Maybe` value is `Nothing`, then this means that there was no module header.

Constructors

PragmasAndModuleName l [ModulePragma l] (Maybe (ModuleName l)) |

#### Instances

Instances details

Data l => Data (PragmasAndModuleName l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PragmasAndModuleName l -> c (PragmasAndModuleName l) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l) Source #

toConstr :: PragmasAndModuleName l -> Constr Source #

dataTypeOf :: PragmasAndModuleName l -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleName l)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PragmasAndModuleName l)) Source #

gmapT :: (forall b. Data b => b -> b) -> PragmasAndModuleName l -> PragmasAndModuleName l Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PragmasAndModuleName l -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PragmasAndModuleName l -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PragmasAndModuleName l -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PragmasAndModuleName l -> m (PragmasAndModuleName l) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PragmasAndModuleName l -> m (PragmasAndModuleName l) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PragmasAndModuleName l -> m (PragmasAndModuleName l) Source #

Show l => Show (PragmasAndModuleName l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods showsPrec :: Int -> PragmasAndModuleName l -> ShowS Source # show :: PragmasAndModuleName l -> String Source # showList :: [PragmasAndModuleName l] -> ShowS Source #
Eq l => Eq (PragmasAndModuleName l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods (==) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source # (/=) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source #
Ord l => Ord (PragmasAndModuleName l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

compare :: PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering Source #

(<) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source #

(<=) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source #

(>) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source #

(>=) :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool Source #

max :: PragmasAndModuleName l -> PragmasAndModuleName l -> PragmasAndModuleName l Source #

min :: PragmasAndModuleName l -> PragmasAndModuleName l -> PragmasAndModuleName l Source #

Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleName SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))

data PragmasAndModuleHead l Source #

Constructors

PragmasAndModuleHead l [ModulePragma l] (Maybe (ModuleHead l)) |

#### Instances

Instances details

Data l => Data (PragmasAndModuleHead l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PragmasAndModuleHead l -> c (PragmasAndModuleHead l) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l) Source #

toConstr :: PragmasAndModuleHead l -> Constr Source #

dataTypeOf :: PragmasAndModuleHead l -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleHead l)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PragmasAndModuleHead l)) Source #

gmapT :: (forall b. Data b => b -> b) -> PragmasAndModuleHead l -> PragmasAndModuleHead l Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PragmasAndModuleHead l -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PragmasAndModuleHead l -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l) Source #

Show l => Show (PragmasAndModuleHead l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods showsPrec :: Int -> PragmasAndModuleHead l -> ShowS Source # show :: PragmasAndModuleHead l -> String Source # showList :: [PragmasAndModuleHead l] -> ShowS Source #
Eq l => Eq (PragmasAndModuleHead l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods (==) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source # (/=) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source #
Ord l => Ord (PragmasAndModuleHead l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

compare :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering Source #

(<) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source #

(<=) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source #

(>) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source #

(>=) :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool Source #

max :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> PragmasAndModuleHead l Source #

min :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> PragmasAndModuleHead l Source #

Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (PragmasAndModuleHead SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))

data ModuleHeadAndImports l Source #

Constructors

ModuleHeadAndImports l [ModulePragma l] (Maybe (ModuleHead l)) [ImportDecl l] |

#### Instances

Instances details

Data l => Data (ModuleHeadAndImports l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ModuleHeadAndImports l -> c (ModuleHeadAndImports l) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l) Source #

toConstr :: ModuleHeadAndImports l -> Constr Source #

dataTypeOf :: ModuleHeadAndImports l -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ModuleHeadAndImports l)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ModuleHeadAndImports l)) Source #

gmapT :: (forall b. Data b => b -> b) -> ModuleHeadAndImports l -> ModuleHeadAndImports l Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ModuleHeadAndImports l -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ModuleHeadAndImports l -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l) Source #

Show l => Show (ModuleHeadAndImports l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods showsPrec :: Int -> ModuleHeadAndImports l -> ShowS Source # show :: ModuleHeadAndImports l -> String Source # showList :: [ModuleHeadAndImports l] -> ShowS Source #
Eq l => Eq (ModuleHeadAndImports l) Source # |
Instance details Defined in Language.Haskell.Exts.Parser Methods (==) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source # (/=) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source #
Ord l => Ord (ModuleHeadAndImports l) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

compare :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering Source #

(<) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source #

(<=) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source #

(>) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source #

(>=) :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool Source #

max :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> ModuleHeadAndImports l Source #

min :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> ModuleHeadAndImports l Source #

Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source # |

Instance details

Defined in Language.Haskell.Exts.Parser

Methods

parse :: String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithMode :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) Source #

parseWithComments :: ParseMode -> String -> ParseResult (NonGreedy (ModuleHeadAndImports SrcSpanInfo), [Comment]) Source #

parser :: Maybe [Fixity] -> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))

# Orphan instances

Parseable (Decl SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Decl SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Decl SrcSpanInfo)
Parseable (Exp SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Exp SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Exp SrcSpanInfo)
Parseable (ImportDecl SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (ImportDecl SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (ImportDecl SrcSpanInfo)
Parseable (Module SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Module SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Module SrcSpanInfo)
Parseable (Pat SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Pat SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Pat SrcSpanInfo)
Parseable (Stmt SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Stmt SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Stmt SrcSpanInfo)
Parseable (Type SrcSpanInfo) Source # |
Instance details Methods parse :: String -> ParseResult (Type SrcSpanInfo) Source # parseWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo) Source # parseWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment]) Source # parser :: Maybe [Fixity] -> P (Type SrcSpanInfo)