Cabal-3.6.3.0: A framework for packaging Haskell software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Parsec

Synopsis

Documentation

class Parsec a where Source #

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

Instances details
Parsec OpenModule Source #
>>> eitherParsec "Includes2-0.1.0.0-inplace-mysql:Database.MySQL" :: Either String OpenModule
Right (OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "Includes2-0.1.0.0-inplace-mysql"})) (ModuleName "Database.MySQL"))
Instance details

Defined in Distribution.Backpack

Parsec OpenUnitId Source #
>>> eitherParsec "foobar" :: Either String OpenUnitId
Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))
>>> eitherParsec "foo[Str=text-1.2.3:Data.Text.Text]" :: Either String OpenUnitId
Right (IndefFullUnitId (ComponentId "foo") (fromList [(ModuleName "Str",OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "text-1.2.3"})) (ModuleName "Data.Text.Text"))]))
Instance details

Defined in Distribution.Backpack

Parsec AbiTag Source # 
Instance details

Defined in Distribution.Compiler

Methods

parsec :: CabalParsing m => m AbiTag Source #

Parsec CompilerFlavor Source # 
Instance details

Defined in Distribution.Compiler

Parsec CompilerId Source # 
Instance details

Defined in Distribution.Compiler

Parsec FilePathNT Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec SpecLicense Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec SpecVersion Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec TestedWith Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec Token Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m Token Source #

Parsec Token' Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m Token' Source #

Parsec License Source # 
Instance details

Defined in Distribution.License

Parsec ModuleName Source # 
Instance details

Defined in Distribution.ModuleName

Parsec License Source #
>>> eitherParsec "BSD-3-Clause AND MIT" :: Either String License
Right (License (EAnd (ELicense (ELicenseId BSD_3_Clause) Nothing) (ELicense (ELicenseId MIT) Nothing)))
>>> eitherParsec "NONE" :: Either String License
Right NONE
Instance details

Defined in Distribution.SPDX.License

Parsec LicenseExceptionId Source # 
Instance details

Defined in Distribution.SPDX.LicenseExceptionId

Parsec LicenseExpression Source # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec SimpleLicenseExpression Source # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec LicenseId Source #
>>> eitherParsec "BSD-3-Clause" :: Either String LicenseId
Right BSD_3_Clause
>>> eitherParsec "BSD3" :: Either String LicenseId
Left "...Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?"
Instance details

Defined in Distribution.SPDX.LicenseId

Parsec LicenseRef Source # 
Instance details

Defined in Distribution.SPDX.LicenseReference

Parsec HaddockTarget Source # 
Instance details

Defined in Distribution.Simple.Setup

Parsec TestShowDetails Source # 
Instance details

Defined in Distribution.Simple.Setup

Parsec Arch Source # 
Instance details

Defined in Distribution.System

Methods

parsec :: CabalParsing m => m Arch Source #

Parsec OS Source # 
Instance details

Defined in Distribution.System

Methods

parsec :: CabalParsing m => m OS Source #

Parsec Platform Source # 
Instance details

Defined in Distribution.System

Parsec AbiDependency Source # 
Instance details

Defined in Distribution.Types.AbiDependency

Parsec AbiHash Source # 
Instance details

Defined in Distribution.Types.AbiHash

Parsec BenchmarkType Source # 
Instance details

Defined in Distribution.Types.BenchmarkType

Parsec BuildType Source # 
Instance details

Defined in Distribution.Types.BuildType

Parsec ComponentId Source # 
Instance details

Defined in Distribution.Types.ComponentId

Parsec ComponentName Source # 
Instance details

Defined in Distribution.Types.ComponentName

Parsec Dependency Source #
>>> simpleParsec "mylib:sub" :: Maybe Dependency
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))
>>> simpleParsec "mylib:{sub1,sub2}" :: Maybe Dependency
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
>>> simpleParsec "mylib:{ sub1 , sub2 }" :: Maybe Dependency
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
>>> simpleParsec "mylib:{ sub1 , sub2 } ^>= 42" :: Maybe Dependency
Just (Dependency (PackageName "mylib") (MajorBoundVersion (mkVersion [42])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub1") :| [LSubLibName (UnqualComponentName "sub2")])))
>>> simpleParsec "mylib:{ } ^>= 42" :: Maybe Dependency
Nothing
>>> traverse_ print (map simpleParsec ["mylib:mylib", "mylib:{mylib}", "mylib:{mylib,sublib}" ] :: [Maybe Dependency])
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [])))
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [])))
Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LMainLibName :| [LSubLibName (UnqualComponentName "sublib")])))

Spaces around colon are not allowed:

>>> map simpleParsec ["mylib: sub", "mylib :sub", "mylib: {sub1,sub2}", "mylib :{sub1,sub2}"] :: [Maybe Dependency]
[Nothing,Nothing,Nothing,Nothing]

Sublibrary syntax is accepted since cabal-version: 3.0

>>> map (`simpleParsec'` "mylib:sub") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe Dependency]
[Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))]
Instance details

Defined in Distribution.Types.Dependency

Parsec ExeDependency Source #

Examples

>>> simpleParsec "happy:happy" :: Maybe ExeDependency
Just (ExeDependency (PackageName "happy") (UnqualComponentName "happy") (OrLaterVersion (mkVersion [0])))
>>> simpleParsec "happy:happy >= 1.19.12" :: Maybe ExeDependency
Just (ExeDependency (PackageName "happy") (UnqualComponentName "happy") (OrLaterVersion (mkVersion [1,19,12])))
>>> simpleParsec "happy:happy>=1.19.12" :: Maybe ExeDependency
Just (ExeDependency (PackageName "happy") (UnqualComponentName "happy") (OrLaterVersion (mkVersion [1,19,12])))
>>> simpleParsec "happy : happy >= 1.19.12" :: Maybe ExeDependency
Nothing
>>> simpleParsec "happy: happy >= 1.19.12" :: Maybe ExeDependency
Nothing
>>> simpleParsec "happy :happy >= 1.19.12" :: Maybe ExeDependency
Nothing
Instance details

Defined in Distribution.Types.ExeDependency

Parsec ExecutableScope Source # 
Instance details

Defined in Distribution.Types.ExecutableScope

Parsec ExposedModule Source # 
Instance details

Defined in Distribution.Types.ExposedModule

Parsec FlagAssignment Source #
>>> simpleParsec "" :: Maybe FlagAssignment
Just (fromList [])
>>> simpleParsec "+foo -bar" :: Maybe FlagAssignment
Just (fromList [(FlagName "bar",(1,False)),(FlagName "foo",(1,True))])
>>> simpleParsec "-none -any" :: Maybe FlagAssignment
Just (fromList [(FlagName "any",(1,False)),(FlagName "none",(1,False))])
>>> simpleParsec "+foo -foo +foo +foo" :: Maybe FlagAssignment
Just (fromList [(FlagName "foo",(4,True))])
>>> simpleParsec "+foo -bar baz" :: Maybe FlagAssignment
Nothing

Since: Cabal-3.4.0.0

Instance details

Defined in Distribution.Types.Flag

Parsec FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Parsec LibVersionInfo Source # 
Instance details

Defined in Distribution.Types.ForeignLib

Parsec ForeignLibOption Source # 
Instance details

Defined in Distribution.Types.ForeignLibOption

Parsec ForeignLibType Source # 
Instance details

Defined in Distribution.Types.ForeignLibType

Parsec IncludeRenaming Source # 
Instance details

Defined in Distribution.Types.IncludeRenaming

Parsec LegacyExeDependency Source # 
Instance details

Defined in Distribution.Types.LegacyExeDependency

Parsec LibraryVisibility Source # 
Instance details

Defined in Distribution.Types.LibraryVisibility

Parsec Mixin Source #
>>> simpleParsec "mylib" :: Maybe Mixin
Just (Mixin {mixinPackageName = PackageName "mylib", mixinLibraryName = LMainLibName, mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})
>>> simpleParsec "thatlib:sublib" :: Maybe Mixin
Just (Mixin {mixinPackageName = PackageName "thatlib", mixinLibraryName = LSubLibName (UnqualComponentName "sublib"), mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})
>>> simpleParsec "thatlib:thatlib" :: Maybe Mixin
Just (Mixin {mixinPackageName = PackageName "thatlib", mixinLibraryName = LMainLibName, mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})

Sublibrary syntax is accepted since cabal-version: 3.4.

>>> map (`simpleParsec'` "mylib:sub") [CabalSpecV3_0, CabalSpecV3_4] :: [Maybe Mixin]
[Nothing,Just (Mixin {mixinPackageName = PackageName "mylib", mixinLibraryName = LSubLibName (UnqualComponentName "sub"), mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})]
Instance details

Defined in Distribution.Types.Mixin

Methods

parsec :: CabalParsing m => m Mixin Source #

Parsec Module Source # 
Instance details

Defined in Distribution.Types.Module

Methods

parsec :: CabalParsing m => m Module Source #

Parsec ModuleReexport Source # 
Instance details

Defined in Distribution.Types.ModuleReexport

Parsec ModuleRenaming Source # 
Instance details

Defined in Distribution.Types.ModuleRenaming

Parsec MungedPackageId Source #
>>> simpleParsec "foo-bar-0" :: Maybe MungedPackageId
Just (MungedPackageId {mungedName = MungedPackageName (PackageName "foo-bar") LMainLibName, mungedVersion = mkVersion [0]})
>>> simpleParsec "foo-bar" :: Maybe MungedPackageId
Just (MungedPackageId {mungedName = MungedPackageName (PackageName "foo-bar") LMainLibName, mungedVersion = mkVersion []})
>>> simpleParsec "z-foo-bar-z-baz-0" :: Maybe MungedPackageId
Just (MungedPackageId {mungedName = MungedPackageName (PackageName "foo-bar") (LSubLibName (UnqualComponentName "baz")), mungedVersion = mkVersion [0]})
>>> simpleParsec "foo-bar-0-0" :: Maybe MungedPackageId
Nothing
>>> simpleParsec "foo-bar.0" :: Maybe MungedPackageId
Nothing
>>> simpleParsec "foo-bar.4-2" :: Maybe MungedPackageId
Nothing
Instance details

Defined in Distribution.Types.MungedPackageId

Parsec MungedPackageName Source #
>>> simpleParsec "servant" :: Maybe MungedPackageName
Just (MungedPackageName (PackageName "servant") LMainLibName)
>>> simpleParsec "z-servant-z-lackey" :: Maybe MungedPackageName
Just (MungedPackageName (PackageName "servant") (LSubLibName (UnqualComponentName "lackey")))
>>> simpleParsec "z-servant-zz" :: Maybe MungedPackageName
Just (MungedPackageName (PackageName "z-servant-zz") LMainLibName)
Instance details

Defined in Distribution.Types.MungedPackageName

Parsec PackageIdentifier Source #
>>> simpleParsec "foo-bar-0" :: Maybe PackageIdentifier
Just (PackageIdentifier {pkgName = PackageName "foo-bar", pkgVersion = mkVersion [0]})
>>> simpleParsec "foo-bar" :: Maybe PackageIdentifier
Just (PackageIdentifier {pkgName = PackageName "foo-bar", pkgVersion = mkVersion []})

Note: Stricter than Text instance

>>> simpleParsec "foo-bar-0-0" :: Maybe PackageIdentifier
Nothing
>>> simpleParsec "foo-bar.0" :: Maybe PackageIdentifier
Nothing
>>> simpleParsec "foo-bar.4-2" :: Maybe PackageIdentifier
Nothing
>>> simpleParsec "1.2.3" :: Maybe PackageIdentifier
Nothing
Instance details

Defined in Distribution.Types.PackageId

Parsec PackageName Source # 
Instance details

Defined in Distribution.Types.PackageName

Parsec PackageVersionConstraint Source #
>>> simpleParsec "foo" :: Maybe PackageVersionConstraint
Just (PackageVersionConstraint (PackageName "foo") (OrLaterVersion (mkVersion [0])))
>>> simpleParsec "foo >=2.0" :: Maybe PackageVersionConstraint
Just (PackageVersionConstraint (PackageName "foo") (OrLaterVersion (mkVersion [2,0])))
>>> simpleParsec "foo-2.0" :: Maybe PackageVersionConstraint
Just (PackageVersionConstraint (PackageName "foo") (ThisVersion (mkVersion [2,0])))
Instance details

Defined in Distribution.Types.PackageVersionConstraint

Parsec PkgconfigDependency Source # 
Instance details

Defined in Distribution.Types.PkgconfigDependency

Parsec PkgconfigName Source # 
Instance details

Defined in Distribution.Types.PkgconfigName

Parsec PkgconfigVersion Source #
>>> simpleParsec "1.0.2n" :: Maybe PkgconfigVersion
Just (PkgconfigVersion "1.0.2n")
>>> simpleParsec "0.3.5+ds" :: Maybe PkgconfigVersion
Nothing
Instance details

Defined in Distribution.Types.PkgconfigVersion

Parsec PkgconfigVersionRange Source # 
Instance details

Defined in Distribution.Types.PkgconfigVersionRange

Parsec KnownRepoType Source # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoKind Source # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoType Source # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec TestType Source # 
Instance details

Defined in Distribution.Types.TestType

Parsec DefUnitId Source # 
Instance details

Defined in Distribution.Types.UnitId

Parsec UnitId Source #

The textual format for UnitId coincides with the format GHC accepts for -package-id.

Instance details

Defined in Distribution.Types.UnitId

Methods

parsec :: CabalParsing m => m UnitId Source #

Parsec UnqualComponentName Source # 
Instance details

Defined in Distribution.Types.UnqualComponentName

Parsec Version Source # 
Instance details

Defined in Distribution.Types.Version

Parsec VersionRange Source #
>>> simpleParsec "^>= 3.4" :: Maybe VersionRange
Just (MajorBoundVersion (mkVersion [3,4]))

Small history:

-any and -none removed in 3.4 Use >=0 and <0 instead.

>>> map (`simpleParsec'` "-none") [CabalSpecV3_0, CabalSpecV3_4] :: [Maybe VersionRange]
[Just (EarlierVersion (mkVersion [0])),Nothing]

Set operations are introduced in 3.0

>>> map (`simpleParsec'` "^>= { 1.2 , 1.3 }") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe VersionRange]
[Nothing,Just (UnionVersionRanges (MajorBoundVersion (mkVersion [1,2])) (MajorBoundVersion (mkVersion [1,3])))]

^>= is introduced in 2.0

>>> map (`simpleParsec'` "^>=1.2") [CabalSpecV1_24, CabalSpecV2_0] :: [Maybe VersionRange]
[Nothing,Just (MajorBoundVersion (mkVersion [1,2]))]

-none is introduced in 1.22

>>> map (`simpleParsec'` "-none") [CabalSpecV1_20, CabalSpecV1_22] :: [Maybe VersionRange]
[Nothing,Just (EarlierVersion (mkVersion [0]))]

Operators are introduced in 1.8. Issues only a warning.

>>> map (`simpleParsecW'` "== 1 || ==2") [CabalSpecV1_6, CabalSpecV1_8] :: [Maybe VersionRange]
[Nothing,Just (UnionVersionRanges (ThisVersion (mkVersion [1])) (ThisVersion (mkVersion [2])))]

Wild-version ranges are introduced in 1.6. Issues only a warning.

>>> map (`simpleParsecW'` "== 1.2.*") [CabalSpecV1_4, CabalSpecV1_6] :: [Maybe VersionRange]
[Nothing,Just (IntersectVersionRanges (OrLaterVersion (mkVersion [1,2])) (EarlierVersion (mkVersion [1,3])))]
Instance details

Defined in Distribution.Types.VersionRange.Internal

Parsec Verbosity Source #

Parser verbosity

>>> explicitEitherParsec parsecVerbosity "normal"
Right (Verbosity {vLevel = Normal, vFlags = fromList [], vQuiet = False})
>>> explicitEitherParsec parsecVerbosity "normal+nowrap  "
Right (Verbosity {vLevel = Normal, vFlags = fromList [VNoWrap], vQuiet = False})
>>> explicitEitherParsec parsecVerbosity "normal+nowrap +markoutput"
Right (Verbosity {vLevel = Normal, vFlags = fromList [VNoWrap,VMarkOutput], vQuiet = False})
>>> explicitEitherParsec parsecVerbosity "normal +nowrap +markoutput"
Right (Verbosity {vLevel = Normal, vFlags = fromList [VNoWrap,VMarkOutput], vQuiet = False})
>>> explicitEitherParsec parsecVerbosity "normal+nowrap+markoutput"
Right (Verbosity {vLevel = Normal, vFlags = fromList [VNoWrap,VMarkOutput], vQuiet = False})
>>> explicitEitherParsec parsecVerbosity "deafening+nowrap+stdout+stderr+callsite+callstack"
Right (Verbosity {vLevel = Deafening, vFlags = fromList [VCallStack,VCallSite,VNoWrap,VStderr], vQuiet = False})

Note: this parser will eat trailing spaces.

Instance details

Defined in Distribution.Verbosity

Parsec Extension Source # 
Instance details

Defined in Language.Haskell.Extension

Parsec Language Source # 
Instance details

Defined in Language.Haskell.Extension

Parsec Bool Source # 
Instance details

Defined in Distribution.Parsec

Methods

parsec :: CabalParsing m => m Bool Source #

FieldGrammar Parsec ParsecFieldGrammar Source # 
Instance details

Defined in Distribution.FieldGrammar.Parsec

Methods

blurFieldGrammar :: ALens' a b -> ParsecFieldGrammar b d -> ParsecFieldGrammar a d Source #

uniqueFieldAla :: (Parsec b, Newtype a b) => FieldName -> (a -> b) -> ALens' s a -> ParsecFieldGrammar s a Source #

booleanFieldDef :: FieldName -> ALens' s Bool -> Bool -> ParsecFieldGrammar s Bool Source #

optionalFieldAla :: (Parsec b, Newtype a b) => FieldName -> (a -> b) -> ALens' s (Maybe a) -> ParsecFieldGrammar s (Maybe a) Source #

optionalFieldDefAla :: (Parsec b, Newtype a b, Eq a) => FieldName -> (a -> b) -> ALens' s a -> a -> ParsecFieldGrammar s a Source #

freeTextField :: FieldName -> ALens' s (Maybe String) -> ParsecFieldGrammar s (Maybe String) Source #

freeTextFieldDef :: FieldName -> ALens' s String -> ParsecFieldGrammar s String Source #

freeTextFieldDefST :: FieldName -> ALens' s ShortText -> ParsecFieldGrammar s ShortText Source #

monoidalFieldAla :: (Parsec b, Monoid a, Newtype a b) => FieldName -> (a -> b) -> ALens' s a -> ParsecFieldGrammar s a Source #

prefixedFields :: FieldName -> ALens' s [(String, String)] -> ParsecFieldGrammar s [(String, String)] Source #

knownField :: FieldName -> ParsecFieldGrammar s () Source #

hiddenField :: ParsecFieldGrammar s a -> ParsecFieldGrammar s a Source #

deprecatedSince :: CabalSpecVersion -> String -> ParsecFieldGrammar s a -> ParsecFieldGrammar s a Source #

removedIn :: CabalSpecVersion -> String -> ParsecFieldGrammar s a -> ParsecFieldGrammar s a Source #

availableSince :: CabalSpecVersion -> a -> ParsecFieldGrammar s a -> ParsecFieldGrammar s a Source #

availableSinceWarn :: CabalSpecVersion -> ParsecFieldGrammar s a -> ParsecFieldGrammar s a Source #

Parsec a => Parsec (MQuoted a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (MQuoted a) Source #

Parsec a => Parsec (Identity a) Source # 
Instance details

Defined in Distribution.Parsec

Methods

parsec :: CabalParsing m => m (Identity a) Source #

Parsec (SymbolicPath from to) Source # 
Instance details

Defined in Distribution.Utils.Path

Methods

parsec :: CabalParsing m => m (SymbolicPath from to) Source #

(Newtype a b, Sep sep, Parsec b) => Parsec (List sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (List sep b a) Source #

(Newtype a b, Sep sep, Parsec b) => Parsec (NonEmpty' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (NonEmpty' sep b a) Source #

(Newtype a b, Ord a, Sep sep, Parsec b) => Parsec (Set' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (Set' sep b a) Source #

newtype ParsecParser a Source #

Constructors

PP 

Instances

Instances details
CharParsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Parsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

CabalParsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

MonadFail ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Alternative ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Applicative ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Functor ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Methods

fmap :: (a -> b) -> ParsecParser a -> ParsecParser b Source #

(<$) :: a -> ParsecParser b -> ParsecParser a Source #

Monad ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

MonadPlus ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

simpleParsec' :: Parsec a => CabalSpecVersion -> String -> Maybe a Source #

Parse a String with lexemeParsec using specific CabalSpecVersion.

Since: Cabal-3.4.0.0

simpleParsecW' :: Parsec a => CabalSpecVersion -> String -> Maybe a Source #

Parse a String with lexemeParsec using specific CabalSpecVersion. Fail if there are any warnings.

Since: Cabal-3.4.0.0

lexemeParsec :: (CabalParsing m, Parsec a) => m a Source #

parsec could consume trailing spaces, this function will consume.

explicitEitherParsec :: ParsecParser a -> String -> Either String a Source #

Parse a String with given ParsecParser. Trailing whitespace is accepted.

explicitEitherParsec' :: CabalSpecVersion -> ParsecParser a -> String -> Either String a Source #

Parse a String with given ParsecParser and CabalSpecVersion. Trailing whitespace is accepted. See explicitEitherParsec.

Since: Cabal-3.4.0.0

CabalParsing 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

parsecWarning, askCabalSpecVersion

Warnings

data PWarnType Source #

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

true or false, not True or False

PWTVersionTag

there are version with tags

PWTNewSyntax

New syntax used, but no cabal-version: >= 1.2 specified

PWTOldSyntax

Old syntax used, and cabal-version >= 1.2 specified

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.

PWTVersionOperator

Version operators used (without cabal-version: 1.8)

PWTVersionWildcard

Version wildcard used (without cabal-version: 1.6)

PWTSpecVersion

Warnings about cabal-version format.

PWTEmptyFilePath

Empty filepath, i.e. literally ""

PWTExperimental

Experimental feature

Instances

Instances details
Bounded PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Enum PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Generic PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarnType :: Type -> Type Source #

Show PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Binary PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarnType -> () Source #

Eq PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Ord PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

type Rep PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

type Rep PWarnType = D1 ('MetaData "PWarnType" "Distribution.Parsec.Warning" "Cabal-3.6.3.0" 'False) ((((C1 ('MetaCons "PWTOther" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTUTF" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTBoolCase" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "PWTVersionTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTNewSyntax" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTOldSyntax" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PWTDeprecatedField" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTInvalidSubsection" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTUnknownField" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "PWTUnknownSection" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTTrailingFields" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PWTExtraMainIs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTExtraTestModule" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "PWTExtraBenchmarkModule" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTLexNBSP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTLexBOM" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "PWTLexTab" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTQuirkyCabalFile" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTDoubleDash" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PWTMultipleSingularField" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWTBuildTypeDefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTVersionOperator" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "PWTVersionWildcard" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTSpecVersion" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PWTEmptyFilePath" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTExperimental" 'PrefixI 'False) (U1 :: Type -> Type))))))

data PWarning Source #

Parser warning.

Instances

Instances details
Generic PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarning :: Type -> Type Source #

Show PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Binary PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarning -> () Source #

type Rep PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Errors

data PError Source #

Parser error.

Constructors

PError Position String 

Instances

Instances details
Generic PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Associated Types

type Rep PError :: Type -> Type Source #

Show PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Binary PError Source # 
Instance details

Defined in Distribution.Parsec.Error

NFData PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Methods

rnf :: PError -> () Source #

type Rep PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Position

data Position Source #

1-indexed row and column positions in a file.

Constructors

Position !Int !Int 

Instances

Instances details
Generic Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Associated Types

type Rep Position :: Type -> Type Source #

Show Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Binary Position Source # 
Instance details

Defined in Distribution.Parsec.Position

NFData Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Methods

rnf :: Position -> () Source #

Eq Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Ord Position Source # 
Instance details

Defined in Distribution.Parsec.Position

type Rep Position Source # 
Instance details

Defined in Distribution.Parsec.Position

type Rep Position = D1 ('MetaData "Position" "Distribution.Parsec.Position" "Cabal-3.6.3.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)))

incPos :: Int -> Position -> Position Source #

Shift position by n columns to the right.

retPos :: Position -> Position Source #

Shift position to beginning of next row.

Utilities

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

parsecLeadingCommaNonEmpty :: CabalParsing m => m a -> m (NonEmpty a) Source #

Since: Cabal-3.4.0.0

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.