Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Parsec a where
- parsec :: CabalParsing m => m a
- newtype ParsecParser a = PP {
- unPP :: CabalSpecVersion -> Parsec FieldLineStream [PWarning] a
- runParsecParser :: ParsecParser a -> FilePath -> FieldLineStream -> Either ParseError a
- runParsecParser' :: CabalSpecVersion -> ParsecParser a -> FilePath -> FieldLineStream -> Either ParseError a
- simpleParsec :: Parsec a => String -> Maybe a
- lexemeParsec :: (CabalParsing m, Parsec a) => m a
- eitherParsec :: Parsec a => String -> Either String a
- explicitEitherParsec :: ParsecParser a -> String -> Either String a
- class (CharParsing m, MonadPlus m, MonadFail m) => CabalParsing m where
- parsecWarning :: PWarnType -> String -> m ()
- parsecHaskellString :: m String
- askCabalSpecVersion :: m CabalSpecVersion
- data PWarnType
- = PWTOther
- | PWTUTF
- | PWTBoolCase
- | PWTVersionTag
- | PWTNewSyntax
- | PWTOldSyntax
- | PWTDeprecatedField
- | PWTInvalidSubsection
- | PWTUnknownField
- | PWTUnknownSection
- | PWTTrailingFields
- | PWTExtraMainIs
- | PWTExtraTestModule
- | PWTExtraBenchmarkModule
- | PWTLexNBSP
- | PWTLexBOM
- | PWTLexTab
- | PWTQuirkyCabalFile
- | PWTDoubleDash
- | PWTMultipleSingularField
- | PWTBuildTypeDefault
- data PWarning = PWarning !PWarnType !Position String
- showPWarning :: FilePath -> PWarning -> String
- data PError = PError Position String
- showPError :: FilePath -> PError -> String
- data Position = Position !Int !Int
- incPos :: Int -> Position -> Position
- retPos :: Position -> Position
- showPos :: Position -> String
- zeroPos :: Position
- parsecToken :: CabalParsing m => m String
- parsecToken' :: CabalParsing m => m String
- parsecFilePath :: CabalParsing m => m FilePath
- parsecQuoted :: CabalParsing m => m a -> m a
- parsecMaybeQuoted :: CabalParsing m => m a -> m a
- parsecCommaList :: CabalParsing m => m a -> m [a]
- parsecLeadingCommaList :: CabalParsing m => m a -> m [a]
- parsecOptCommaList :: CabalParsing m => m a -> m [a]
- parsecLeadingOptCommaList :: CabalParsing m => m a -> m [a]
- parsecStandard :: (CabalParsing m, Parsec ver) => (ver -> String -> a) -> m a
- parsecUnqualComponentName :: CabalParsing m => m String
Documentation
Class for parsing with parsec
. Mainly used for .cabal
file fields.
For parsing .cabal
like file structure, see Distribution.Fields.
parsec :: CabalParsing m => m a Source #
Instances
newtype ParsecParser a Source #
PP | |
|
Instances
runParsecParser :: ParsecParser a -> FilePath -> FieldLineStream -> Either ParseError a Source #
Run ParsecParser
with cabalSpecLatest
.
runParsecParser' :: CabalSpecVersion -> ParsecParser a -> FilePath -> FieldLineStream -> Either ParseError a Source #
Like runParsecParser
but lets specify CabalSpecVersion
used.
Since: Cabal-3.0.0.0
simpleParsec :: Parsec a => String -> Maybe a Source #
Parse a String
with lexemeParsec
.
lexemeParsec :: (CabalParsing m, Parsec a) => m a Source #
parsec
could consume trailing spaces, this function will consume.
eitherParsec :: Parsec a => String -> Either String a Source #
Parse a String
with lexemeParsec
.
explicitEitherParsec :: ParsecParser a -> String -> Either String a Source #
Parse a String
with given ParsecParser
. Trailing whitespace is accepted.
CabalParsing and and diagnostics
class (CharParsing m, MonadPlus m, MonadFail m) => CabalParsing m where Source #
Parsing class which
- can report Cabal parser warnings.
- knows
cabal-version
we work with
parsecWarning :: PWarnType -> String -> m () Source #
parsecHaskellString :: m String Source #
Instances
Warnings
Type of parser warning. We do classify warnings.
Different application may decide not to show some, or have fatal behaviour on others
PWTOther | Unclassified warning |
PWTUTF | Invalid UTF encoding |
PWTBoolCase |
|
PWTVersionTag | there are version with tags |
PWTNewSyntax | New syntax used, but no |
PWTOldSyntax | Old syntax used, and |
PWTDeprecatedField | |
PWTInvalidSubsection | |
PWTUnknownField | |
PWTUnknownSection | |
PWTTrailingFields | |
PWTExtraMainIs | extra main-is field |
PWTExtraTestModule | extra test-module field |
PWTExtraBenchmarkModule | extra benchmark-module field |
PWTLexNBSP | |
PWTLexBOM | |
PWTLexTab | |
PWTQuirkyCabalFile | legacy cabal file that we know how to patch |
PWTDoubleDash | Double dash token, most likely it's a mistake - it's not a comment |
PWTMultipleSingularField | e.g. name or version should be specified only once. |
PWTBuildTypeDefault | Workaround for derive-package having build-type: Default. See https://github.com/haskell/cabal/issues/5020. |
Instances
Parser warning.
Instances
Show PWarning # | |
Generic PWarning # | |
Binary PWarning # | |
NFData PWarning # | |
Defined in Distribution.Parsec.Warning | |
type Rep PWarning # | |
Defined in Distribution.Parsec.Warning type Rep PWarning = D1 ('MetaData "PWarning" "Distribution.Parsec.Warning" "Cabal-3.1.0.0" 'False) (C1 ('MetaCons "PWarning" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PWarnType) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Position) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))) |
Errors
Parser error.
Instances
Show PError # | |
Generic PError # | |
Binary PError # | |
NFData PError # | |
Defined in Distribution.Parsec.Error | |
type Rep PError # | |
Defined in Distribution.Parsec.Error type Rep PError = D1 ('MetaData "PError" "Distribution.Parsec.Error" "Cabal-3.1.0.0" 'False) (C1 ('MetaCons "PError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) |
Position
1-indexed row and column positions in a file.
Instances
Eq Position # | |
Ord Position # | |
Defined in Distribution.Parsec.Position | |
Show Position # | |
Generic Position # | |
Binary Position # | |
NFData Position # | |
Defined in Distribution.Parsec.Position | |
type Rep Position # | |
Defined in Distribution.Parsec.Position type Rep Position = D1 ('MetaData "Position" "Distribution.Parsec.Position" "Cabal-3.1.0.0" 'False) (C1 ('MetaCons "Position" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int))) |
Utilities
parsecToken :: CabalParsing m => m String Source #
[^ ,]
parsecToken' :: CabalParsing m => m String Source #
[^ ]
parsecFilePath :: CabalParsing m => m FilePath Source #
parsecQuoted :: CabalParsing m => m a -> m a Source #
Content isn't unquoted
parsecMaybeQuoted :: CabalParsing m => m a -> m a Source #
parsecMaybeQuoted p =
.parsecQuoted
p | p
parsecCommaList :: CabalParsing m => m a -> m [a] Source #
parsecLeadingCommaList :: CabalParsing m => m a -> m [a] Source #
Like parsecCommaList
but accept leading or trailing comma.
p (comma p)* -- p sepBy
comma
(comma p)* -- leading comma
(p comma)* -- trailing comma
parsecOptCommaList :: CabalParsing m => m a -> m [a] Source #
parsecLeadingOptCommaList :: CabalParsing m => m a -> m [a] Source #
Like parsecOptCommaList
but
- require all or none commas
- accept leading or trailing comma.
p (comma p)* -- p sepBy
comma
(comma p)* -- leading comma
(p comma)* -- trailing comma
p* -- no commas: many p
Since: Cabal-3.0.0.0
parsecStandard :: (CabalParsing m, Parsec ver) => (ver -> String -> a) -> m a Source #
Parse a benchmark/test-suite types.
parsecUnqualComponentName :: CabalParsing m => m String Source #