Safe Haskell | None |
---|---|
Language | Haskell2010 |
Distribution.Parsec
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
.
Methods
parsec :: CabalParsing m => m a Source #
Instances
Parsec Bool Source # | |
Defined in Distribution.Parsec Methods parsec :: CabalParsing m => m Bool Source # |
|
Parsec Version Source # | |
Defined in Distribution.Types.Version Methods parsec :: CabalParsing m => m Version Source # |
|
Parsec VersionRange Source # | |
Defined in Distribution.Types.VersionRange.Internal Methods parsec :: CabalParsing m => m VersionRange Source # |
|
Parsec RepoType Source # | |
Defined in Distribution.Types.SourceRepo Methods parsec :: CabalParsing m => m RepoType Source # |
|
Parsec RepoKind Source # | |
Defined in Distribution.Types.SourceRepo Methods parsec :: CabalParsing m => m RepoKind Source # |
|
Parsec PkgconfigVersion Source # |
|
Defined in Distribution.Types.PkgconfigVersion Methods parsec :: CabalParsing m => m PkgconfigVersion Source # |
|
Parsec PkgconfigVersionRange Source # | |
Defined in Distribution.Types.PkgconfigVersionRange Methods parsec :: CabalParsing m => m PkgconfigVersionRange Source # |
|
Parsec PkgconfigName Source # | |
Defined in Distribution.Types.PkgconfigName Methods parsec :: CabalParsing m => m PkgconfigName Source # |
|
Parsec PkgconfigDependency Source # | |
Defined in Distribution.Types.PkgconfigDependency Methods parsec :: CabalParsing m => m PkgconfigDependency Source # |
|
Parsec PackageName Source # | |
Defined in Distribution.Types.PackageName Methods parsec :: CabalParsing m => m PackageName Source # |
|
Parsec UnqualComponentName Source # | |
Defined in Distribution.Types.UnqualComponentName Methods parsec :: CabalParsing m => m UnqualComponentName Source # |
|
Parsec PackageVersionConstraint Source # | |
Defined in Distribution.Types.PackageVersionConstraint Methods parsec :: CabalParsing m => m PackageVersionConstraint Source # |
|
Parsec LibraryVisibility Source # | |
Defined in Distribution.Types.LibraryVisibility Methods parsec :: CabalParsing m => m LibraryVisibility Source # |
|
Parsec MungedPackageName Source # |
|
Defined in Distribution.Types.MungedPackageName Methods parsec :: CabalParsing m => m MungedPackageName Source # |
|
Parsec ForeignLibType Source # | |
Defined in Distribution.Types.ForeignLibType Methods parsec :: CabalParsing m => m ForeignLibType Source # |
|
Parsec ForeignLibOption Source # | |
Defined in Distribution.Types.ForeignLibOption Methods parsec :: CabalParsing m => m ForeignLibOption Source # |
|
Parsec FlagName Source # | |
Defined in Distribution.Types.Flag Methods parsec :: CabalParsing m => m FlagName Source # |
|
Parsec ExecutableScope Source # | |
Defined in Distribution.Types.ExecutableScope Methods parsec :: CabalParsing m => m ExecutableScope Source # |
|
Parsec ComponentName Source # | |
Defined in Distribution.Types.ComponentName Methods parsec :: CabalParsing m => m ComponentName Source # |
|
Parsec ComponentId Source # | |
Defined in Distribution.Types.ComponentId Methods parsec :: CabalParsing m => m ComponentId Source # |
|
Parsec BuildType Source # | |
Defined in Distribution.Types.BuildType Methods parsec :: CabalParsing m => m BuildType Source # |
|
Parsec AbiHash Source # | |
Defined in Distribution.Types.AbiHash Methods parsec :: CabalParsing m => m AbiHash Source # |
|
Parsec Platform Source # | |
Defined in Distribution.System Methods parsec :: CabalParsing m => m Platform Source # |
|
Parsec Arch Source # | |
Defined in Distribution.System Methods parsec :: CabalParsing m => m Arch Source # |
|
Parsec OS Source # | |
Defined in Distribution.System Methods parsec :: CabalParsing m => m OS Source # |
|
Parsec LicenseRef Source # | |
Defined in Distribution.SPDX.LicenseReference Methods parsec :: CabalParsing m => m LicenseRef Source # |
|
Parsec LicenseId Source # |
|
Defined in Distribution.SPDX.LicenseId Methods parsec :: CabalParsing m => m LicenseId Source # |
|
Parsec LicenseExceptionId Source # | |
Defined in Distribution.SPDX.LicenseExceptionId Methods parsec :: CabalParsing m => m LicenseExceptionId Source # |
|
Parsec SimpleLicenseExpression Source # | |
Defined in Distribution.SPDX.LicenseExpression Methods parsec :: CabalParsing m => m SimpleLicenseExpression Source # |
|
Parsec LicenseExpression Source # | |
Defined in Distribution.SPDX.LicenseExpression Methods parsec :: CabalParsing m => m LicenseExpression Source # |
|
Parsec License Source # |
|
Defined in Distribution.SPDX.License Methods parsec :: CabalParsing m => m License Source # |
|
Parsec ModuleName Source # | |
Defined in Distribution.ModuleName Methods parsec :: CabalParsing m => m ModuleName Source # |
|
Parsec ModuleRenaming Source # | |
Defined in Distribution.Types.ModuleRenaming Methods parsec :: CabalParsing m => m ModuleRenaming Source # |
|
Parsec IncludeRenaming Source # | |
Defined in Distribution.Types.IncludeRenaming Methods parsec :: CabalParsing m => m IncludeRenaming Source # |
|
Parsec Mixin Source # | |
Defined in Distribution.Types.Mixin Methods parsec :: CabalParsing m => m Mixin Source # |
|
Parsec ModuleReexport Source # | |
Defined in Distribution.Types.ModuleReexport Methods parsec :: CabalParsing m => m ModuleReexport Source # |
|
Parsec TestType Source # | |
Defined in Distribution.Types.TestType Methods parsec :: CabalParsing m => m TestType Source # |
|
Parsec PackageIdentifier Source # |
Note:
Stricter than
|
Defined in Distribution.Types.PackageId Methods parsec :: CabalParsing m => m PackageIdentifier Source # |
|
Parsec DefUnitId Source # | |
Defined in Distribution.Types.UnitId Methods parsec :: CabalParsing m => m DefUnitId Source # |
|
Parsec UnitId Source # |
The textual format for
|
Defined in Distribution.Types.UnitId Methods parsec :: CabalParsing m => m UnitId Source # |
|
Parsec Module Source # | |
Defined in Distribution.Types.Module Methods parsec :: CabalParsing m => m Module Source # |
|
Parsec OpenModule Source # |
|
Defined in Distribution.Backpack Methods parsec :: CabalParsing m => m OpenModule Source # |
|
Parsec OpenUnitId Source # |
|
Defined in Distribution.Backpack Methods parsec :: CabalParsing m => m OpenUnitId Source # |
|
Parsec ExposedModule Source # | |
Defined in Distribution.Types.ExposedModule Methods parsec :: CabalParsing m => m ExposedModule Source # |
|
Parsec MungedPackageId Source # |
|
Defined in Distribution.Types.MungedPackageId Methods parsec :: CabalParsing m => m MungedPackageId Source # |
|
Parsec LegacyExeDependency Source # | |
Defined in Distribution.Types.LegacyExeDependency Methods parsec :: CabalParsing m => m LegacyExeDependency Source # |
|
Parsec ExeDependency Source # |
Examples
|
Defined in Distribution.Types.ExeDependency Methods parsec :: CabalParsing m => m ExeDependency Source # |
|
Parsec Dependency Source # |
Spaces around colon are not allowed:
|
Defined in Distribution.Types.Dependency Methods parsec :: CabalParsing m => m Dependency Source # |
|
Parsec BenchmarkType Source # | |
Defined in Distribution.Types.BenchmarkType Methods parsec :: CabalParsing m => m BenchmarkType Source # |
|
Parsec AbiDependency Source # | |
Defined in Distribution.Types.AbiDependency Methods parsec :: CabalParsing m => m AbiDependency Source # |
|
Parsec License Source # | |
Defined in Distribution.License Methods parsec :: CabalParsing m => m License Source # |
|
Parsec Extension Source # | |
Defined in Language.Haskell.Extension Methods parsec :: CabalParsing m => m Extension Source # |
|
Parsec Language Source # | |
Defined in Language.Haskell.Extension Methods parsec :: CabalParsing m => m Language Source # |
|
Parsec AbiTag Source # | |
Defined in Distribution.Compiler Methods parsec :: CabalParsing m => m AbiTag Source # |
|
Parsec CompilerId Source # | |
Defined in Distribution.Compiler Methods parsec :: CabalParsing m => m CompilerId Source # |
|
Parsec CompilerFlavor Source # | |
Defined in Distribution.Compiler Methods parsec :: CabalParsing m => m CompilerFlavor Source # |
|
Parsec LibVersionInfo Source # | |
Defined in Distribution.Types.ForeignLib Methods parsec :: CabalParsing m => m LibVersionInfo Source # |
|
Parsec FilePathNT Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m FilePathNT Source # |
|
Parsec TestedWith Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m TestedWith Source # |
|
Parsec SpecLicense Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m SpecLicense Source # |
|
Parsec SpecVersion Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m SpecVersion Source # |
|
Parsec Token' Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m Token' Source # |
|
Parsec Token Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m Token Source # |
|
Parsec TestShowDetails Source # | |
Defined in Distribution.Simple.Setup Methods parsec :: CabalParsing m => m TestShowDetails Source # |
|
Parsec HaddockTarget Source # | |
Defined in Distribution.Simple.Setup Methods parsec :: CabalParsing m => m HaddockTarget Source # |
|
Parsec a => Parsec ( Identity a) Source # | |
Defined in Distribution.Parsec Methods parsec :: CabalParsing m => m ( Identity a) Source # |
|
Parsec a => Parsec ( MQuoted a) Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m ( MQuoted a) Source # |
|
( Newtype a b, Ord a, Sep sep, Parsec b) => Parsec ( Set' sep b a) Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m ( Set' sep b a) Source # |
|
( Newtype a b, Sep sep, Parsec b) => Parsec ( List sep b a) Source # | |
Defined in Distribution.Parsec.Newtypes Methods parsec :: CabalParsing m => m ( List sep b a) Source # |
newtype ParsecParser a Source #
Constructors
PP | |
Fields
|
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: 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
Minimal complete definition
Methods
parsecWarning :: PWarnType -> String -> m () Source #
parsecHaskellString :: m String Source #
Instances
CabalParsing ParsecParser Source # | |
Defined in Distribution.Parsec Methods parsecWarning :: PWarnType -> String -> ParsecParser () Source # parsecHaskellString :: ParsecParser String Source # askCabalSpecVersion :: ParsecParser CabalSpecVersion Source # |
Warnings
Type of parser warning. We do classify warnings.
Different application may decide not to show some, or have fatal behaviour on others
Constructors
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 Source # | |
Generic PWarning Source # | |
Binary PWarning Source # | |
NFData PWarning Source # | |
Defined in Distribution.Parsec.Warning |
|
type Rep PWarning Source # | |
Defined in Distribution.Parsec.Warning
type
Rep
PWarning
=
D1
('
MetaData
"PWarning" "Distribution.Parsec.Warning" "Cabal-3.2.1.0-3w1fQQbNnuQ5xlFGwVXcPy" '
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 Source # | |
Generic PError Source # | |
Binary PError Source # | |
NFData PError Source # | |
Defined in Distribution.Parsec.Error |
|
type Rep PError Source # | |
Defined in Distribution.Parsec.Error
type
Rep
PError
=
D1
('
MetaData
"PError" "Distribution.Parsec.Error" "Cabal-3.2.1.0-3w1fQQbNnuQ5xlFGwVXcPy" '
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 Source # | |
Ord Position Source # | |
Defined in Distribution.Parsec.Position |
|
Show Position Source # | |
Generic Position Source # | |
Binary Position Source # | |
NFData Position Source # | |
Defined in Distribution.Parsec.Position |
|
type Rep Position Source # | |
Defined in Distribution.Parsec.Position
type
Rep
Position
=
D1
('
MetaData
"Position" "Distribution.Parsec.Position" "Cabal-3.2.1.0-3w1fQQbNnuQ5xlFGwVXcPy" '
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: 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 #