Cabal-3.0.0.0: A framework for packaging Haskell software
Safe HaskellNone
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 Bool # 
Instance details

Defined in Distribution.Parsec

Methods

parsec :: CabalParsing m => m Bool Source #

Parsec Version # 
Instance details

Defined in Distribution.Types.Version

Parsec VersionRange # 
Instance details

Defined in Distribution.Types.VersionRange.Internal

Parsec RepoType # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec RepoKind # 
Instance details

Defined in Distribution.Types.SourceRepo

Parsec PkgconfigVersion # 
Instance details

Defined in Distribution.Types.PkgconfigVersion

Parsec PkgconfigVersionRange # 
Instance details

Defined in Distribution.Types.PkgconfigVersionRange

Parsec PkgconfigName # 
Instance details

Defined in Distribution.Types.PkgconfigName

Parsec PkgconfigDependency # 
Instance details

Defined in Distribution.Types.PkgconfigDependency

Parsec PackageName # 
Instance details

Defined in Distribution.Types.PackageName

Parsec UnqualComponentName # 
Instance details

Defined in Distribution.Types.UnqualComponentName

Parsec PackageVersionConstraint # 
Instance details

Defined in Distribution.Types.PackageVersionConstraint

Parsec LibraryVisibility # 
Instance details

Defined in Distribution.Types.LibraryVisibility

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

Defined in Distribution.Types.ForeignLibType

Parsec ForeignLibOption # 
Instance details

Defined in Distribution.Types.ForeignLibOption

Parsec ExecutableScope # 
Instance details

Defined in Distribution.Types.ExecutableScope

Parsec ComponentName # 
Instance details

Defined in Distribution.Types.ComponentName

Parsec ComponentId # 
Instance details

Defined in Distribution.Types.ComponentId

Parsec BuildType # 
Instance details

Defined in Distribution.Types.BuildType

Parsec AbiHash # 
Instance details

Defined in Distribution.Types.AbiHash

Parsec Platform # 
Instance details

Defined in Distribution.System

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

Defined in Distribution.SPDX.LicenseReference

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

Defined in Distribution.SPDX.LicenseExceptionId

Parsec SimpleLicenseExpression # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

Parsec LicenseExpression # 
Instance details

Defined in Distribution.SPDX.LicenseExpression

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

Defined in Distribution.ModuleName

Parsec ModuleRenaming # 
Instance details

Defined in Distribution.Types.ModuleRenaming

Parsec IncludeRenaming # 
Instance details

Defined in Distribution.Types.IncludeRenaming

Parsec Mixin # 
Instance details

Defined in Distribution.Types.Mixin

Methods

parsec :: CabalParsing m => m Mixin Source #

Parsec ModuleReexport # 
Instance details

Defined in Distribution.Types.ModuleReexport

Parsec TestType # 
Instance details

Defined in Distribution.Types.TestType

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

Defined in Distribution.Types.Module

Methods

parsec :: CabalParsing m => m Module Source #

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

Defined in Distribution.Types.ExposedModule

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

Defined in Distribution.Types.LegacyExeDependency

Parsec ExeDependency # 
Instance details

Defined in Distribution.Types.ExeDependency

Parsec Dependency # 
Instance details

Defined in Distribution.Types.Dependency

Parsec BenchmarkType # 
Instance details

Defined in Distribution.Types.BenchmarkType

Parsec AbiDependency # 
Instance details

Defined in Distribution.Types.AbiDependency

Parsec License # 
Instance details

Defined in Distribution.License

Parsec Extension # 
Instance details

Defined in Language.Haskell.Extension

Parsec Language # 
Instance details

Defined in Language.Haskell.Extension

Parsec AbiTag # 
Instance details

Defined in Distribution.Compiler

Methods

parsec :: CabalParsing m => m AbiTag Source #

Parsec CompilerId # 
Instance details

Defined in Distribution.Compiler

Parsec CompilerFlavor # 
Instance details

Defined in Distribution.Compiler

Parsec LibVersionInfo # 
Instance details

Defined in Distribution.Types.ForeignLib

Parsec FlagName # 
Instance details

Defined in Distribution.Types.GenericPackageDescription

Parsec FilePathNT # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec TestedWith # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec SpecLicense # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec SpecVersion # 
Instance details

Defined in Distribution.Parsec.Newtypes

Parsec Token' # 
Instance details

Defined in Distribution.Parsec.Newtypes

Methods

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

Parsec Token # 
Instance details

Defined in Distribution.Parsec.Newtypes

Methods

parsec :: CabalParsing m => m Token Source #

Parsec TestShowDetails # 
Instance details

Defined in Distribution.Simple.Setup

Parsec HaddockTarget # 
Instance details

Defined in Distribution.Simple.Setup

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

Defined in Distribution.Parsec

Methods

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

Parsec a => Parsec (MQuoted a) # 
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) # 
Instance details

Defined in Distribution.Parsec.Newtypes

Methods

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

newtype ParsecParser a Source #

Constructors

PP 

Instances

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

MonadFail ParsecParser # 
Instance details

Defined in Distribution.Parsec

Applicative ParsecParser # 
Instance details

Defined in Distribution.Parsec

Alternative ParsecParser # 
Instance details

Defined in Distribution.Parsec

MonadPlus ParsecParser # 
Instance details

Defined in Distribution.Parsec

Parsing ParsecParser # 
Instance details

Defined in Distribution.Parsec

CharParsing ParsecParser # 
Instance details

Defined in Distribution.Parsec

CabalParsing ParsecParser # 
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

Instances details
Bounded PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Enum PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Eq PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Ord PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

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

Binary PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

NFData PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

Methods

rnf :: PWarnType -> () Source #

type Rep PWarnType # 
Instance details

Defined in Distribution.Parsec.Warning

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

data PWarning Source #

Parser warning.

Instances

Instances details
Show PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

Generic PWarning # 
Instance details

Defined in Distribution.Parsec.Warning

Associated Types

type Rep PWarning :: Type -> Type Source #

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

Defined in Distribution.Parsec.Error

Generic PError # 
Instance details

Defined in Distribution.Parsec.Error

Associated Types

type Rep PError :: Type -> Type Source #

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

Defined in Distribution.Parsec.Position

Ord Position # 
Instance details

Defined in Distribution.Parsec.Position

Show Position # 
Instance details

Defined in Distribution.Parsec.Position

Generic Position # 
Instance details

Defined in Distribution.Parsec.Position

Associated Types

type Rep Position :: Type -> Type Source #

Binary Position # 
Instance details

Defined in Distribution.Parsec.Position

NFData Position # 
Instance details

Defined in Distribution.Parsec.Position

Methods

rnf :: Position -> () Source #

type Rep Position # 
Instance details

Defined in Distribution.Parsec.Position

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

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.