base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow 2002
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilitynon-portable (uses Text.ParserCombinators.ReadP)
Safe HaskellTrustworthy
LanguageHaskell2010

Text.ParserCombinators.ReadPrec

Contents

Description

This library defines parser combinators for precedence parsing.

Synopsis

Documentation

data ReadPrec a #

Instances
Monad ReadPrec #

Since: base-2.1

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

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

(>>) :: ReadPrec a -> ReadPrec b -> ReadPrec b #

return :: a -> ReadPrec a #

fail :: String -> ReadPrec a #

Functor ReadPrec #

Since: base-2.1

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

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

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

MonadFail ReadPrec #

Since: base-4.9.0.0

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

fail :: String -> ReadPrec a #

Applicative ReadPrec #

Since: base-4.6.0.0

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

pure :: a -> ReadPrec a #

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

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

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

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

MonadPlus ReadPrec #

Since: base-2.1

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

mzero :: ReadPrec a #

mplus :: ReadPrec a -> ReadPrec a -> ReadPrec a #

Alternative ReadPrec #

Since: base-4.6.0.0

Instance details

Defined in Text.ParserCombinators.ReadPrec

Methods

empty :: ReadPrec a #

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

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

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

Precedences

type Prec = Int #

Precedence operations

lift :: ReadP a -> ReadPrec a #

Lift a precedence-insensitive ReadP to a ReadPrec.

prec :: Prec -> ReadPrec a -> ReadPrec a #

(prec n p) checks whether the precedence context is less than or equal to n, and

  • if not, fails
  • if so, parses p in context n.

step :: ReadPrec a -> ReadPrec a #

Increases the precedence context by one.

reset :: ReadPrec a -> ReadPrec a #

Resets the precedence context to zero.

Other operations

All are based directly on their similarly-named ReadP counterparts.

get :: ReadPrec Char #

Consumes and returns the next character. Fails if there is no input left.

look :: ReadPrec String #

Look-ahead: returns the part of the input that is left, without consuming it.

(+++) :: ReadPrec a -> ReadPrec a -> ReadPrec a #

Symmetric choice.

(<++) :: ReadPrec a -> ReadPrec a -> ReadPrec a #

Local, exclusive, left-biased choice: If left parser locally produces any result at all, then right parser is not used.

pfail :: ReadPrec a #

Always fails.

choice :: [ReadPrec a] -> ReadPrec a #

Combines all parsers in the specified list.

Converters