MaintainerCS 131, Programming Languages (Melissa O'Neill, Chris Stone, Ben Wiedermann)
Safe HaskellSafe

ParserBase

Description

NOTE: You do not need to understand the code in this file. It uses some features of Haskell that we have not yet learned.

Synopsis

Documentation

data Parser a #

Has the capacity to invoke a parsing function on an input string, and look for a result of type a.

Instances
Monad Parser # 
Instance details

Defined in ParserBase

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b #

(>>) :: Parser a -> Parser b -> Parser b

return :: a -> Parser a #

fail :: String -> Parser a #

Functor Parser # 
Instance details

Defined in ParserBase

Methods

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

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

Applicative Parser # 
Instance details

Defined in ParserBase

Methods

pure :: a -> Parser a

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

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c

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

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

Alternative Parser # 
Instance details

Defined in ParserBase

Methods

empty :: Parser a #

(<|>) :: Parser a -> Parser a -> Parser a #

some :: Parser a -> Parser [a] #

many :: Parser a -> Parser [a] #

MonadPlus Parser # 
Instance details

Defined in ParserBase

Methods

mzero :: Parser a

mplus :: Parser a -> Parser a -> Parser a

pfail :: Parser a #

A parser that always fails.

get :: Parser Char #

Get a single character from the input. Fails if the input is empty.

parse :: Parser a -> String -> a #

Given a 'Parser a' and an input string, return a value of type a if the parser matches the entire input string.

parseFile :: Parser a -> String -> IO a #

Given a 'Parser a' and the path to a file, return a value of type 'IO a' if the parser matches the entire contents of the file.

parseNamed :: Parser a -> String -> String -> a #

(<||>) :: Parser a -> Parser a -> Parser a infixl 3 #

Alternatives. Succeeds if either parser succeeds. If the parse fails, the error information comes from the second parser.

succeeding :: a -> Parser a -> Parser a #

eof :: Parser () #

(<|>) :: Alternative f => f a -> f a -> f a #

some :: Alternative f => f a -> f [a] #

many :: Alternative f => f a -> f [a] #

class Applicative f => Alternative (f :: Type -> Type) #

Minimal complete definition

empty, (<|>)

Instances
Alternative [] 
Instance details

Defined in GHC.Base

Methods

empty :: [a] #

(<|>) :: [a] -> [a] -> [a] #

some :: [a] -> [[a]] #

many :: [a] -> [[a]] #

Alternative Maybe 
Instance details

Defined in GHC.Base

Methods

empty :: Maybe a #

(<|>) :: Maybe a -> Maybe a -> Maybe a #

some :: Maybe a -> Maybe [a] #

many :: Maybe a -> Maybe [a] #

Alternative IO 
Instance details

Defined in GHC.Base

Methods

empty :: IO a #

(<|>) :: IO a -> IO a -> IO a #

some :: IO a -> IO [a] #

many :: IO a -> IO [a] #

Alternative ZipList 
Instance details

Defined in Control.Applicative

Methods

empty :: ZipList a #

(<|>) :: ZipList a -> ZipList a -> ZipList a #

some :: ZipList a -> ZipList [a] #

many :: ZipList a -> ZipList [a] #

Alternative P 
Instance details

Defined in Text.ParserCombinators.ReadP

Methods

empty :: P a #

(<|>) :: P a -> P a -> P a #

some :: P a -> P [a] #

many :: P a -> P [a] #

Alternative ReadP 
Instance details

Defined in Text.ParserCombinators.ReadP

Methods

empty :: ReadP a #

(<|>) :: ReadP a -> ReadP a -> ReadP a #

some :: ReadP a -> ReadP [a] #

many :: ReadP a -> ReadP [a] #

Alternative Parser # 
Instance details

Defined in ParserBase

Methods

empty :: Parser a #

(<|>) :: Parser a -> Parser a -> Parser a #

some :: Parser a -> Parser [a] #

many :: Parser a -> Parser [a] #

MonadPlus m => Alternative (WrappedMonad m) 
Instance details

Defined in Control.Applicative

Methods

empty :: WrappedMonad m a #

(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a #

some :: WrappedMonad m a -> WrappedMonad m [a] #

many :: WrappedMonad m a -> WrappedMonad m [a] #

ArrowPlus a => Alternative (ArrowMonad a) 
Instance details

Defined in Control.Arrow

Methods

empty :: ArrowMonad a a0 #

(<|>) :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #

some :: ArrowMonad a a0 -> ArrowMonad a [a0] #

many :: ArrowMonad a a0 -> ArrowMonad a [a0] #

(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) 
Instance details

Defined in Control.Applicative

Methods

empty :: WrappedArrow a b a0 #

(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #

some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) #

Instances
MonadPlus [] 
Instance details

Defined in GHC.Base

Methods

mzero :: [a]

mplus :: [a] -> [a] -> [a]

MonadPlus Maybe 
Instance details

Defined in GHC.Base

Methods

mzero :: Maybe a

mplus :: Maybe a -> Maybe a -> Maybe a

MonadPlus IO 
Instance details

Defined in GHC.Base

Methods

mzero :: IO a

mplus :: IO a -> IO a -> IO a

MonadPlus P 
Instance details

Defined in Text.ParserCombinators.ReadP

Methods

mzero :: P a

mplus :: P a -> P a -> P a

MonadPlus ReadP 
Instance details

Defined in Text.ParserCombinators.ReadP

Methods

mzero :: ReadP a

mplus :: ReadP a -> ReadP a -> ReadP a

MonadPlus Parser # 
Instance details

Defined in ParserBase

Methods

mzero :: Parser a

mplus :: Parser a -> Parser a -> Parser a

(ArrowApply a, ArrowPlus a) => MonadPlus (ArrowMonad a) 
Instance details

Defined in Control.Arrow

Methods

mzero :: ArrowMonad a a0

mplus :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0

empty :: Alternative f => f a #

join :: Monad m => m (m a) -> m a #

mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a #