Cabal-syntax-3.12.1.0: A library for working with .cabal files

License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Distribution.Fields.LexerMonad

Description

Synopsis

- type InputStream = ByteString
- data LexState = LexState {
  - curPos :: !Position
  - curInput :: !InputStream
  - curCode :: !StartCode
  - warnings :: [LexWarning]
  }
- data LexResult a = LexResult !LexState a
- newtype Lex a = Lex {
  - unLex :: LexState -> LexResult a
  }
- execLexer :: Lex a -> InputStream -> ([LexWarning], a)
- getPos :: Lex Position
- setPos :: Position -> Lex ()
- adjustPos :: (Position -> Position) -> Lex ()
- getInput :: Lex InputStream
- setInput :: InputStream -> Lex ()
- getStartCode :: Lex Int
- setStartCode :: Int -> Lex ()
- data LexWarning = LexWarning !LexWarningType !Position
- data LexWarningType
  - = LexWarningNBSP
  - | LexWarningBOM
  - | LexWarningTab
  - | LexInconsistentIndentation
  - | LexBraces
- addWarning :: LexWarningType -> Lex ()
- addWarningAt :: Position -> LexWarningType -> Lex ()
- toPWarnings :: [LexWarning] -> [PWarning]

# Documentation

type InputStream = ByteString Source #

data LexState Source #

Constructors

LexState |

Fields

- curPos :: !Position

  position at current input location

- curInput :: !InputStream

  the current input

- curCode :: !StartCode

  lexer code

- warnings :: [LexWarning]

data LexResult a Source #

Constructors

LexResult !LexState a |

newtype Lex a Source #

Constructors

Lex |

Fields

- unLex :: LexState -> LexResult a

#### Instances

Instances details

Applicative Lex Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods pure :: a -> Lex a # (<*>) :: Lex (a -> b) -> Lex a -> Lex b # liftA2 :: (a -> b -> c) -> Lex a -> Lex b -> Lex c # (*>) :: Lex a -> Lex b -> Lex b # (<*) :: Lex a -> Lex b -> Lex a #
Functor Lex Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods fmap :: (a -> b) -> Lex a -> Lex b # (<$) :: a -> Lex b -> Lex a #
Monad Lex Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods (>>=) :: Lex a -> (a -> Lex b) -> Lex b # (>>) :: Lex a -> Lex b -> Lex b # return :: a -> Lex a #

execLexer :: Lex a -> InputStream -> ([LexWarning], a) Source #

Execute the given lexer on the supplied input stream.

getPos :: Lex Position Source #

setPos :: Position -> Lex () Source #

adjustPos :: (Position -> Position) -> Lex () Source #

getInput :: Lex InputStream Source #

setInput :: InputStream -> Lex () Source #

getStartCode :: Lex Int Source #

setStartCode :: Int -> Lex () Source #

data LexWarning Source #

Constructors

LexWarning !LexWarningType !Position |

#### Instances

Instances details

Show LexWarning Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods showsPrec :: Int -> LexWarning -> ShowS # show :: LexWarning -> String # showList :: [LexWarning] -> ShowS #

data LexWarningType Source #

Constructors

LexWarningNBSP | Encountered non breaking space
LexWarningBOM | BOM at the start of the cabal file
LexWarningTab | Leading tags
LexInconsistentIndentation | indentation decreases
LexBraces | Brace syntax used

#### Instances

Instances details

Show LexWarningType Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods showsPrec :: Int -> LexWarningType -> ShowS # show :: LexWarningType -> String # showList :: [LexWarningType] -> ShowS #
Eq LexWarningType Source # |
Instance details Defined in Distribution.Fields.LexerMonad Methods (==) :: LexWarningType -> LexWarningType -> Bool # (/=) :: LexWarningType -> LexWarningType -> Bool #
Ord LexWarningType Source # |

Instance details

Defined in Distribution.Fields.LexerMonad

Methods

compare :: LexWarningType -> LexWarningType -> Ordering #

(<) :: LexWarningType -> LexWarningType -> Bool #

(<=) :: LexWarningType -> LexWarningType -> Bool #

(>) :: LexWarningType -> LexWarningType -> Bool #

(>=) :: LexWarningType -> LexWarningType -> Bool #

max :: LexWarningType -> LexWarningType -> LexWarningType #

min :: LexWarningType -> LexWarningType -> LexWarningType #

addWarning :: LexWarningType -> Lex () Source #

Add warning at the current position

addWarningAt :: Position -> LexWarningType -> Lex () Source #

Add warning at specific position

toPWarnings :: [LexWarning] -> [PWarning] Source #