haskell-src-exts-simple-1.22.0.0: A simplified view on the haskell-src-exts AST

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Exts.Simple.Parser

Description

This module partially reexports Language.Haskell.Exts.Parser with adaptations.

Synopsis

Documentation

pattern ListOf :: forall a. [a] -> ListOf a Source #

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

parse :: (Parseable (ast SrcSpanInfo), Functor ast) => String -> ParseResult (ast ()) Source #

unListOf :: ListOf a -> [a] #

newtype NonGreedy a #

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

Instances
Functor NonGreedy 
Instance details

Defined in Language.Haskell.Exts.Parser

Methods

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

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

Eq a => Eq (NonGreedy a) 
Instance details

Defined in Language.Haskell.Exts.Parser

Methods

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

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

Data a => Data (NonGreedy a) 
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) #

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

toConstr :: NonGreedy a -> Constr #

dataTypeOf :: NonGreedy a -> DataType #

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

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

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

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

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

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

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

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

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

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

Ord a => Ord (NonGreedy a) 
Instance details

Defined in Language.Haskell.Exts.Parser

Show a => Show (NonGreedy a) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) 
Instance details

Defined in Language.Haskell.Exts.Parser

defaultParseMode :: ParseMode #

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.

fromParseResult :: ParseResult a -> a #

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

class Parseable ast #

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

Instances
Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) 
Instance details

Defined in Language.Haskell.Exts.Parser

Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) 
Instance details

Defined in Language.Haskell.Exts.Parser

data ParseResult a #

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
Monad ParseResult 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Functor ParseResult 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Methods

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

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

MonadFail ParseResult 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Methods

fail :: String -> ParseResult a #

Applicative ParseResult 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Methods

pure :: a -> ParseResult a #

(<*>) :: ParseResult (a -> b) -> ParseResult a -> ParseResult b #

liftA2 :: (a -> b -> c) -> ParseResult a -> ParseResult b -> ParseResult c #

(*>) :: ParseResult a -> ParseResult b -> ParseResult b #

(<*) :: ParseResult a -> ParseResult b -> ParseResult a #

Eq a => Eq (ParseResult a) 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Ord a => Ord (ParseResult a) 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Show a => Show (ParseResult a) 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

Semigroup m => Semigroup (ParseResult m) 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

(Monoid m, Semigroup m) => Monoid (ParseResult m) 
Instance details

Defined in Language.Haskell.Exts.ParseMonad

data ParseMode #

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