Cabal-3.0.0.0: A framework for packaging Haskell software

Safe HaskellNone
LanguageHaskell2010

Distribution.Parsec

Contents

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

Defined in Distribution.Parsec

Methods

parsec :: CabalParsing m => m Bool Source #

Parsec Version Source # 
Instance details

Defined in Distribution.Types.Version

Parsec VersionRange Source # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Parsec RepoType Source # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoKind Source # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec PkgconfigVersion Source # 
Instance details

Defined in Distribution.Types.PkgconfigVersion

Parsec PkgconfigVersionRange Source # 
Instance details

Defined in Distribution.Types.PkgconfigVersionRange

Parsec PkgconfigName Source # 
Instance details

Defined in Distribution.Types.PkgconfigName

Parsec PkgconfigDependency Source # 
Instance details

Defined in Distribution.Types.PkgconfigDependency

Parsec PackageName Source # 
Instance details

Defined in Distribution.Types.PackageName

Parsec UnqualComponentName Source # 
Instance details

Defined in Distribution.Types.UnqualComponentName

Parsec PackageVersionConstraint Source # 
Instance details

Defined in Distribution.Types.PackageVersionConstraint

Parsec LibraryVisibility Source # 
Instance details

Defined in Distribution.Types.LibraryVisibility

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

Defined in Distribution.Types.ForeignLibType

Parsec ForeignLibOption Source # 
Instance details

Defined in Distribution.Types.ForeignLibOption

Parsec ExecutableScope Source # 
Instance details

Defined in Distribution.Types.ExecutableScope

Parsec ComponentName Source # 
Instance details

Defined in Distribution.Types.ComponentName

Parsec ComponentId Source # 
Instance details

Defined in Distribution.Types.ComponentId

Parsec BuildType Source # 
Instance details

Defined in Distribution.Types.BuildType

Parsec AbiHash Source # 
Instance details

Defined in Distribution.Types.AbiHash

Parsec Platform Source # 
Instance details

Defined in Distribution.System

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

Defined in Distribution.SPDX.LicenseReference

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

Defined in Distribution.SPDX.LicenseExceptionId

Parsec SimpleLicenseExpression Source # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec LicenseExpression Source # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

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

Defined in Distribution.ModuleName

Parsec ModuleRenaming Source # 
Instance details

Defined in Distribution.Types.ModuleRenaming

Parsec IncludeRenaming Source # 
Instance details

Defined in Distribution.Types.IncludeRenaming

Parsec Mixin Source # 
Instance details

Defined in Distribution.Types.Mixin

Methods

parsec :: CabalParsing m => m Mixin Source #

Parsec ModuleReexport Source # 
Instance details

Defined in Distribution.Types.ModuleReexport

Parsec TestType Source # 
Instance details

Defined in Distribution.Types.TestType

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

Defined in Distribution.Types.Module

Methods

parsec :: CabalParsing m => m Module Source #

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

Defined in Distribution.Types.ExposedModule

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

Defined in Distribution.Types.LegacyExeDependency

Parsec ExeDependency Source # 
Instance details

Defined in Distribution.Types.ExeDependency

Parsec Dependency Source # 
Instance details

Defined in Distribution.Types.Dependency

Parsec BenchmarkType Source # 
Instance details

Defined in Distribution.Types.BenchmarkType

Parsec AbiDependency Source # 
Instance details

Defined in Distribution.Types.AbiDependency

Parsec License Source # 
Instance details

Defined in Distribution.License

Parsec Extension Source # 
Instance details

Defined in Language.Haskell.Extension

Parsec Language Source # 
Instance details

Defined in Language.Haskell.Extension

Parsec AbiTag Source # 
Instance details

Defined in Distribution.Compiler

Methods

parsec :: CabalParsing m => m AbiTag Source #

Parsec CompilerId Source # 
Instance details

Defined in Distribution.Compiler

Parsec CompilerFlavor Source # 
Instance details

Defined in Distribution.Compiler

Parsec LibVersionInfo Source # 
Instance details

Defined in Distribution.Types.ForeignLib

Parsec FlagName Source # 
Instance details

Defined in Distribution.Types.GenericPackageDescription

Parsec FilePathNT Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec TestedWith Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec SpecLicense Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec SpecVersion Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec Token' Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Methods

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

Parsec Token Source # 
Instance details

Defined in Distribution.Parsec.Newtypes

Methods

parsec :: CabalParsing m => m Token Source #

Parsec TestShowDetails Source # 
Instance details

Defined in Distribution.Simple.Setup

Parsec HaddockTarget Source # 
Instance details

Defined in Distribution.Simple.Setup

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

Defined in Distribution.Parsec

Methods

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

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

Defined in Distribution.Parsec.Newtypes

Methods

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

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

Defined in Distribution.Parsec.Newtypes

Methods

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

newtype ParsecParser a Source #

Constructors

PP 
Instances
Monad 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 #

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

MonadFail ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Methods

fail :: String -> ParsecParser a #

Applicative ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Alternative ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

MonadPlus ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

Parsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

CharParsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

CabalParsing ParsecParser Source # 
Instance details

Defined in Distribution.Parsec

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.

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

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.

Instances
Bounded PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Enum PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Eq PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Ord PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

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

Binary PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarnType -> () #

type Rep PWarnType Source # 
Instance details

Defined in Distribution.Parsec.Warning

type Rep PWarnType = D1 (MetaData "PWarnType" "Distribution.Parsec.Warning" "Cabal-3.0.0.0-Gy7jp3IKeIKC3g3Vs5T0x1" 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))))))

data PWarning Source #

Parser warning.

Instances
Show PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Generic PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarning :: Type -> Type #

Methods

from :: PWarning -> Rep PWarning x #

to :: Rep PWarning x -> PWarning #

Binary PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

put :: PWarning -> Put #

get :: Get PWarning #

putList :: [PWarning] -> Put #

NFData PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarning -> () #

type Rep PWarning Source # 
Instance details

Defined in Distribution.Parsec.Warning

Errors

data PError Source #

Parser error.

Constructors

PError Position String 
Instances
Show PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Generic PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Associated Types

type Rep PError :: Type -> Type #

Methods

from :: PError -> Rep PError x #

to :: Rep PError x -> PError #

Binary PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Methods

put :: PError -> Put #

get :: Get PError #

putList :: [PError] -> Put #

NFData PError Source # 
Instance details

Defined in Distribution.Parsec.Error

Methods

rnf :: PError -> () #

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
Eq Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Ord Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Show Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Generic Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Associated Types

type Rep Position :: Type -> Type #

Methods

from :: Position -> Rep Position x #

to :: Rep Position x -> Position #

Binary Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Methods

put :: Position -> Put #

get :: Get Position #

putList :: [Position] -> Put #

NFData Position Source # 
Instance details

Defined in Distribution.Parsec.Position

Methods

rnf :: Position -> () #

type Rep Position Source # 
Instance details

Defined in Distribution.Parsec.Position

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

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.