dhall-1.12.0: A configuration language guaranteed to terminate

Safe HaskellNone
LanguageHaskell98

Dhall.Parser

Contents

Description

This module contains Dhall's parsing logic

Synopsis

Utilities

exprFromText :: Delta -> Text -> Either ParseError (Expr Src Path) Source #

Parse an expression from Text containing a Dhall program

exprAndHeaderFromText :: Delta -> Text -> Either ParseError (Text, Expr Src Path) Source #

Like exprFromText but also returns the leading comments and whitespace (i.e. header) up to the last newline before the code begins

In other words, if you have a Dhall file of the form:

-- Comment 1
 2

Then this will preserve Comment 1, but not Comment 2

This is used by dhall-format to preserve leading comments and whitespace

Parsers

expr :: Parser (Expr Src Path) Source #

Parser for a top-level Dhall expression

exprA :: Parser a -> Parser (Expr Src a) Source #

Parser for a top-level Dhall expression. The expression is parameterized over any parseable type, allowing the language to be extended as needed.

Types

data Src Source #

Source code extract

Constructors

Src Delta Delta ByteString 

Instances

Eq Src Source # 

Methods

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

(/=) :: Src -> Src -> Bool #

Show Src Source # 

Methods

showsPrec :: Int -> Src -> ShowS #

show :: Src -> String #

showList :: [Src] -> ShowS #

Buildable Src Source # 

Methods

build :: Src -> Builder #

newtype Parser a Source #

A Parser that is almost identical to Text.Trifecta.Parser except treating Haskell-style comments as whitespace

Constructors

Parser 

Fields

Instances

Monad Parser Source # 

Methods

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

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

return :: a -> Parser a #

fail :: String -> Parser a #

Functor Parser Source # 

Methods

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

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

Applicative Parser Source # 

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 Source # 

Methods

empty :: Parser a #

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

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

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

MonadPlus Parser Source # 

Methods

mzero :: Parser a #

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

TokenParsing Parser Source # 
CharParsing Parser Source # 
Parsing Parser Source # 

Methods

try :: Parser a -> Parser a #

(<?>) :: Parser a -> String -> Parser a #

skipMany :: Parser a -> Parser () #

skipSome :: Parser a -> Parser () #

unexpected :: String -> Parser a #

eof :: Parser () #

notFollowedBy :: Show a => Parser a -> Parser () #

DeltaParsing Parser Source # 
MarkParsing Delta Parser Source # 

Methods

mark :: Parser Delta #

release :: Delta -> Parser () #

IsString a => IsString (Parser a) Source # 

Methods

fromString :: String -> Parser a #

Semigroup a => Semigroup (Parser a) Source # 

Methods

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

sconcat :: NonEmpty (Parser a) -> Parser a #

stimes :: Integral b => b -> Parser a -> Parser a #

(Semigroup a, Monoid a) => Monoid (Parser a) Source # 

Methods

mempty :: Parser a #

mappend :: Parser a -> Parser a -> Parser a #

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