haskell-src-1.0.2.0: Support for manipulating Haskell source code

Copyright(c) The GHC Team, 1997-2000
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Language.Haskell.ParseMonad

Contents

Description

Monads for the Haskell parser and lexer.

Synopsis

Parsing

data P a #

Monad for parsing

Instances

Monad P # 

Methods

(>>=) :: P a -> (a -> P b) -> P b

(>>) :: P a -> P b -> P b

return :: a -> P a

fail :: String -> P a

Functor P # 

Methods

fmap :: (a -> b) -> P a -> P b

(<$) :: a -> P b -> P a

Applicative P # 

Methods

pure :: a -> P a

(<*>) :: P (a -> b) -> P a -> P b

(*>) :: P a -> P b -> P b

(<*) :: P a -> P b -> P a

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 # 

Methods

(>>=) :: ParseResult a -> (a -> ParseResult b) -> ParseResult b

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

return :: a -> ParseResult a

fail :: String -> ParseResult a

Functor ParseResult # 

Methods

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

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

Applicative ParseResult # 
Show a => Show (ParseResult a) # 

Methods

showsPrec :: Int -> ParseResult a -> ShowS

show :: ParseResult a -> String

showList :: [ParseResult a] -> ShowS

Monoid m => Monoid (ParseResult m) # 

atSrcLoc :: P a -> SrcLoc -> P a #

data LexContext #

Constructors

NoLayout 
Layout Int 

Instances

Eq LexContext # 

Methods

(==) :: LexContext -> LexContext -> Bool

(/=) :: LexContext -> LexContext -> Bool

Ord LexContext # 
Show LexContext # 

Methods

showsPrec :: Int -> LexContext -> ShowS

show :: LexContext -> String

showList :: [LexContext] -> ShowS

data ParseMode #

Static parameters governing a parse. More to come later, e.g. literate mode, language extensions.

Constructors

ParseMode 

Fields

defaultParseMode :: ParseMode #

Default parameters for a parse, currently just a marker for an unknown filename.

runParserWithMode :: ParseMode -> P a -> String -> ParseResult a #

runParser :: P a -> String -> ParseResult a #

popContext :: P () #

Lexing

data Lex r a #

Instances

Monad (Lex r) # 

Methods

(>>=) :: Lex r a -> (a -> Lex r b) -> Lex r b

(>>) :: Lex r a -> Lex r b -> Lex r b

return :: a -> Lex r a

fail :: String -> Lex r a

Functor (Lex r) # 

Methods

fmap :: (a -> b) -> Lex r a -> Lex r b

(<$) :: a -> Lex r b -> Lex r a

Applicative (Lex r) # 

Methods

pure :: a -> Lex r a

(<*>) :: Lex r (a -> b) -> Lex r a -> Lex r b

(*>) :: Lex r a -> Lex r b -> Lex r b

(<*) :: Lex r a -> Lex r b -> Lex r a

getInput :: Lex r String #

discard :: Int -> Lex r () #

Discard some input characters (these must not include tabs or newlines).

lexNewline :: Lex a () #

Discard the next character, which must be a newline.

lexTab :: Lex a () #

Discard the next character, which must be a tab.

lexWhile :: (Char -> Bool) -> Lex a String #

alternative :: Lex a v -> Lex a (Lex a v) #

checkBOL :: Lex a Bool #

setBOL :: Lex a () #

startToken :: Lex a () #

getOffside :: Lex a Ordering #

popContextL :: String -> Lex a () #