Cabal-1.2.4.0: A framework for packaging Haskell softwareSource codeContentsIndex
Distribution.ParseUtils
Portabilityportable
Stabilityalpha
Maintainerlibraries@haskell.org
Description
Utilities for parsing PackageDescription and InstalledPackageInfo.
Synopsis
type LineNo = Int
data PError
= AmbigousParse String LineNo
| NoParse String LineNo
| TabsError LineNo
| FromString String (Maybe LineNo)
type PWarning = String
locatedErrorMsg :: PError -> (Maybe LineNo, String)
syntaxError :: LineNo -> String -> ParseResult a
warning :: String -> ParseResult ()
runP :: LineNo -> String -> ReadP a a -> String -> ParseResult a
data ParseResult a
= ParseFailed PError
| ParseOk [PWarning] a
catchParseError :: ParseResult a -> (PError -> ParseResult a) -> ParseResult a
parseFail :: PError -> ParseResult a
data Field
= F LineNo String String
| Section LineNo String String [Field]
| IfBlock LineNo String [Field] [Field]
fName :: Field -> String
lineNo :: Field -> LineNo
data FieldDescr a = FieldDescr {
fieldName :: String
fieldGet :: a -> Doc
fieldSet :: LineNo -> String -> a -> ParseResult a
}
readFields :: String -> ParseResult [Field]
parseFilePathQ :: ReadP r FilePath
parseTokenQ :: ReadP r String
parseModuleNameQ :: ReadP r String
parseDependency :: ReadP r Dependency
parsePkgconfigDependency :: ReadP r Dependency
parseOptVersion :: ReadP r Version
parsePackageNameQ :: ReadP r String
parseVersionRangeQ :: ReadP r VersionRange
parseTestedWithQ :: ReadP r (CompilerFlavor, VersionRange)
parseLicenseQ :: ReadP r License
parseExtensionQ :: ReadP r Extension
parseSepList :: ReadP r b -> ReadP r a -> ReadP r [a]
parseCommaList :: ReadP r a -> ReadP r [a]
parseOptCommaList :: ReadP r a -> ReadP r [a]
showFilePath :: FilePath -> Doc
showToken :: String -> Doc
showTestedWith :: (CompilerFlavor, VersionRange) -> Doc
showDependency :: Dependency -> Doc
showFreeText :: String -> Doc
field :: String -> (a -> Doc) -> (ReadP a a) -> FieldDescr a
simpleField :: String -> (a -> Doc) -> (ReadP a a) -> (b -> a) -> (a -> b -> b) -> FieldDescr b
listField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
optsField :: String -> CompilerFlavor -> (b -> [(CompilerFlavor, [String])]) -> ([(CompilerFlavor, [String])] -> b -> b) -> FieldDescr b
liftField :: (b -> a) -> (a -> b -> b) -> FieldDescr a -> FieldDescr b
parseReadS :: Read a => ReadP r a
parseReadSQ :: Read a => ReadP r a
parseQuoted :: ReadP r a -> ReadP r a
Documentation
type LineNo = IntSource
data PError Source
Constructors
AmbigousParse String LineNo
NoParse String LineNo
TabsError LineNo
FromString String (Maybe LineNo)
show/hide Instances
type PWarning = StringSource
locatedErrorMsg :: PError -> (Maybe LineNo, String)Source
syntaxError :: LineNo -> String -> ParseResult aSource
warning :: String -> ParseResult ()Source
runP :: LineNo -> String -> ReadP a a -> String -> ParseResult aSource
data ParseResult a Source
Constructors
ParseFailed PError
ParseOk [PWarning] a
show/hide Instances
catchParseError :: ParseResult a -> (PError -> ParseResult a) -> ParseResult aSource
parseFail :: PError -> ParseResult aSource
data Field Source
Constructors
F LineNo String StringA regular property>: <value field
Section LineNo String String [Field]

A section with a name and possible parameter. The syntactic structure is:

   sectionname> <arg {
     field*
   }
IfBlock LineNo String [Field] [Field]

A conditional block with an optional else branch:

  if condition {
    field*
  } else {
    field*
  }
show/hide Instances
fName :: Field -> StringSource
lineNo :: Field -> LineNoSource
data FieldDescr a Source
Field descriptor. The parameter a parameterizes over where the field's value is stored in.
Constructors
FieldDescr
fieldName :: String
fieldGet :: a -> Doc
fieldSet :: LineNo -> String -> a -> ParseResult afieldSet n str x Parses the field value from the given input string str and stores the result in x if the parse was successful. Otherwise, reports an error on line number n.
readFields :: String -> ParseResult [Field]Source
parseFilePathQ :: ReadP r FilePathSource
parseTokenQ :: ReadP r StringSource
parseModuleNameQ :: ReadP r StringSource
parse a module name
parseDependency :: ReadP r DependencySource
parsePkgconfigDependency :: ReadP r DependencySource
parseOptVersion :: ReadP r VersionSource
parsePackageNameQ :: ReadP r StringSource
parseVersionRangeQ :: ReadP r VersionRangeSource
parseTestedWithQ :: ReadP r (CompilerFlavor, VersionRange)Source
parseLicenseQ :: ReadP r LicenseSource
parseExtensionQ :: ReadP r ExtensionSource
parseSepListSource
::
=> ReadP r b
-> ReadP r aThe parser for the stuff between commas
-> ReadP r [a]
parseCommaListSource
::
=> ReadP r aThe parser for the stuff between commas
-> ReadP r [a]
parseOptCommaListSource
::
=> ReadP r aThe parser for the stuff between commas
-> ReadP r [a]
showFilePath :: FilePath -> DocSource
showToken :: String -> DocSource
showTestedWith :: (CompilerFlavor, VersionRange) -> DocSource
showDependency :: Dependency -> DocSource
showFreeText :: String -> DocSource
Pretty-print free-format text, ensuring that it is vertically aligned, and with blank lines replaced by dots for correct re-parsing.
field :: String -> (a -> Doc) -> (ReadP a a) -> FieldDescr aSource
simpleField :: String -> (a -> Doc) -> (ReadP a a) -> (b -> a) -> (a -> b -> b) -> FieldDescr bSource
listField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr bSource
commaListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr bSource
optsField :: String -> CompilerFlavor -> (b -> [(CompilerFlavor, [String])]) -> ([(CompilerFlavor, [String])] -> b -> b) -> FieldDescr bSource
liftField :: (b -> a) -> (a -> b -> b) -> FieldDescr a -> FieldDescr bSource
parseReadS :: Read a => ReadP r aSource
parseReadSQ :: Read a => ReadP r aSource
Parse something optionally wrapped in quotes.
parseQuoted :: ReadP r a -> ReadP r aSource
Produced by Haddock version 2.1.0