Cabal-3.5.0.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 #
>>> 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 #
>>> 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 # 
Instance details

Defined in Distribution.Compiler

Methods

parsec :: CabalParsing m => m AbiTag Source #

Parsec CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Parsec CompilerId # 
Instance details

Defined in Distribution.Compiler

Parsec FilePathNT # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec SpecLicense # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec SpecVersion # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec TestedWith # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Parsec Token # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m Token Source #

Parsec Token' # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

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

Parsec License # 
Instance details

Defined in Distribution.License

Parsec ModuleName # 
Instance details

Defined in Distribution.ModuleName

Parsec License #
>>> 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 # 
Instance details

Defined in Distribution.SPDX.LicenseExceptionId

Parsec LicenseExpression # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec SimpleLicenseExpression # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec LicenseId #
>>> 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 # 
Instance details

Defined in Distribution.SPDX.LicenseReference

Parsec HaddockTarget # 
Instance details

Defined in Distribution.Simple.Setup

Parsec TestShowDetails # 
Instance details

Defined in Distribution.Simple.Setup

Parsec Arch # 
Instance details

Defined in Distribution.System

Methods

parsec :: CabalParsing m => m Arch Source #

Parsec OS # 
Instance details

Defined in Distribution.System

Methods

parsec :: CabalParsing m => m OS Source #

Parsec Platform # 
Instance details

Defined in Distribution.System

Parsec AbiDependency # 
Instance details

Defined in Distribution.Types.AbiDependency

Parsec AbiHash # 
Instance details

Defined in Distribution.Types.AbiHash

Parsec BenchmarkType # 
Instance details

Defined in Distribution.Types.BenchmarkType

Parsec BuildType # 
Instance details

Defined in Distribution.Types.BuildType

Parsec ComponentId # 
Instance details

Defined in Distribution.Types.ComponentId

Parsec ComponentName # 
Instance details

Defined in Distribution.Types.ComponentName

Parsec Dependency #
>>> 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 #

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 # 
Instance details

Defined in Distribution.Types.ExecutableScope

Parsec ExposedModule # 
Instance details

Defined in Distribution.Types.ExposedModule

Parsec FlagAssignment #
>>> 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 # 
Instance details

Defined in Distribution.Types.Flag

Parsec LibVersionInfo # 
Instance details

Defined in Distribution.Types.ForeignLib

Parsec ForeignLibOption # 
Instance details

Defined in Distribution.Types.ForeignLibOption

Parsec ForeignLibType # 
Instance details

Defined in Distribution.Types.ForeignLibType

Parsec IncludeRenaming # 
Instance details

Defined in Distribution.Types.IncludeRenaming

Parsec LegacyExeDependency # 
Instance details

Defined in Distribution.Types.LegacyExeDependency

Parsec LibraryVisibility # 
Instance details

Defined in Distribution.Types.LibraryVisibility

Parsec Mixin #
>>> 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 # 
Instance details

Defined in Distribution.Types.Module

Methods

parsec :: CabalParsing m => m Module Source #

Parsec ModuleReexport # 
Instance details

Defined in Distribution.Types.ModuleReexport

Parsec ModuleRenaming # 
Instance details

Defined in Distribution.Types.ModuleRenaming

Parsec MungedPackageId #
>>> 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 #
>>> 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 #
>>> 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 # 
Instance details

Defined in Distribution.Types.PackageName

Parsec PackageVersionConstraint #
>>> 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 # 
Instance details

Defined in Distribution.Types.PkgconfigDependency

Parsec PkgconfigName # 
Instance details

Defined in Distribution.Types.PkgconfigName

Parsec PkgconfigVersion #
>>> 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 # 
Instance details

Defined in Distribution.Types.PkgconfigVersionRange

Parsec KnownRepoType # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoKind # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoType # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec TestType # 
Instance details

Defined in Distribution.Types.TestType

Parsec DefUnitId # 
Instance details

Defined in Distribution.Types.UnitId

Parsec UnitId #

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 # 
Instance details

Defined in Distribution.Types.UnqualComponentName

Parsec Version # 
Instance details

Defined in Distribution.Types.Version

Parsec VersionRange #
>>> 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 #

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 # 
Instance details

Defined in Language.Haskell.Extension

Parsec Language # 
Instance details

Defined in Language.Haskell.Extension

Parsec Bool # 
Instance details

Defined in Distribution.Parsec

Methods

parsec :: CabalParsing m => m Bool Source #

FieldGrammar Parsec ParsecFieldGrammar # 
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) # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

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

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

Defined in Distribution.Parsec

Methods

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

Parsec (SymbolicPath from to) # 
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) # 
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) # 
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) # 
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 # 
Instance details

Defined in Distribution.Parsec

Parsing ParsecParser # 
Instance details

Defined in Distribution.Parsec

CabalParsing ParsecParser # 
Instance details

Defined in Distribution.Parsec

MonadFail ParsecParser # 
Instance details

Defined in Distribution.Parsec

Alternative ParsecParser # 
Instance details

Defined in Distribution.Parsec

Applicative ParsecParser # 
Instance details

Defined in Distribution.Parsec

Functor ParsecParser # 
Instance details

Defined in Distribution.Parsec

Methods

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

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

Monad ParsecParser # 
Instance details

Defined in Distribution.Parsec

MonadPlus ParsecParser # 
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 # 
Instance details

Defined in Distribution.Parsec.Warning

Enum PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Generic PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarnType :: Type -> Type Source #

Show PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Binary PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarnType -> () Source #

Eq PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Ord PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

type Rep PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

type Rep PWarnType = D1 ('MetaData "PWarnType" "Distribution.Parsec.Warning" "Cabal-3.5.0.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 # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarning :: Type -> Type Source #

Show PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

Binary PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarning -> () Source #

type Rep PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

Errors

data PError Source #

Parser error.

Constructors

PError Position String 

Instances

Instances details
Generic PError # 
Instance details

Defined in Distribution.Parsec.Error

Associated Types

type Rep PError :: Type -> Type Source #

Show PError # 
Instance details

Defined in Distribution.Parsec.Error

Binary PError # 
Instance details

Defined in Distribution.Parsec.Error

NFData PError # 
Instance details

Defined in Distribution.Parsec.Error

Methods

rnf :: PError -> () Source #

type Rep PError # 
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 # 
Instance details

Defined in Distribution.Parsec.Position

Associated Types

type Rep Position :: Type -> Type Source #

Show Position # 
Instance details

Defined in Distribution.Parsec.Position

Binary Position # 
Instance details

Defined in Distribution.Parsec.Position

NFData Position # 
Instance details

Defined in Distribution.Parsec.Position

Methods

rnf :: Position -> () Source #

Eq Position # 
Instance details

Defined in Distribution.Parsec.Position

Ord Position # 
Instance details

Defined in Distribution.Parsec.Position

type Rep Position # 
Instance details

Defined in Distribution.Parsec.Position

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

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.