| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Distribution.Fields
Description
Utilities to work with .cabal like file structure.
Synopsis
- data Field ann
- data Name ann = Name !ann !FieldName
- data FieldLine ann = FieldLine !ann !ByteString
- data SectionArg ann
- = SecArgName !ann !ByteString
- | SecArgStr !ann !ByteString
- | SecArgOther !ann !ByteString
- type FieldName = ByteString
- readFields :: ByteString -> Either ParseError [Field Position]
- readFields' :: ByteString -> Either ParseError ([Field Position], [LexWarning])
- data ParseResult src a
- runParseResult :: ParseResult src a -> ([PWarningWithSource src], Either (Maybe Version, NonEmpty (PErrorWithSource src)) a)
- parseWarning :: Position -> PWarnType -> String -> ParseResult src ()
- parseWarnings :: [PWarning] -> ParseResult src ()
- parseFailure :: Position -> String -> ParseResult src ()
- parseFatalFailure :: Position -> String -> ParseResult src a
- data PWarnType
- = PWTOther
- | PWTUTF
- | PWTBoolCase
- | PWTVersionTag
- | PWTNewSyntax
- | PWTOldSyntax
- | PWTDeprecatedField
- | PWTInvalidSubsection
- | PWTUnknownField
- | PWTUnknownSection
- | PWTTrailingFields
- | PWTExtraMainIs
- | PWTExtraTestModule
- | PWTExtraBenchmarkModule
- | PWTLexNBSP
- | PWTLexBOM
- | PWTLexTab
- | PWTQuirkyCabalFile
- | PWTDoubleDash
- | PWTMultipleSingularField
- | PWTBuildTypeDefault
- | PWTVersionOperator
- | PWTVersionWildcard
- | PWTSpecVersion
- | PWTEmptyFilePath
- | PWTInconsistentIndentation
- | PWTExperimental
- data PWarning = PWarning {}
- data PWarningWithSource src = PWarningWithSource {
- pwarningSource :: !(PSource src)
- pwarning :: !PWarning
- data PSource src
- = PKnownSource src
- | PUnknownSource
- showPWarning :: FilePath -> PWarning -> String
- showPWarningWithSource :: PWarningWithSource String -> String
- data PError = PError {}
- data PErrorWithSource src = PErrorWithSource {
- perrorSource :: !(PSource src)
- perror :: !PError
- showPError :: FilePath -> PError -> String
- showPErrorWithSource :: PErrorWithSource String -> String
- data CommentPosition
- = CommentBefore [String]
- | CommentAfter [String]
- | NoComment
- data PrettyField ann
- = PrettyField ann FieldName Doc
- | PrettySection ann FieldName [Doc] [PrettyField ann]
- | PrettyEmpty
- showFields :: (ann -> CommentPosition) -> [PrettyField ann] -> String
- genericFromParsecFields :: Applicative f => (FieldName -> [FieldLine ann] -> f Doc) -> (FieldName -> [SectionArg ann] -> f [Doc]) -> [Field ann] -> f [PrettyField ann]
- fromParsecFields :: [Field ann] -> [PrettyField ann]
Types
A Cabal-like file consists of a series of fields (foo: bar) and sections (library ...).
Instances
| Foldable1 Field Source # | Since: 3.12.0.0 |
Defined in Distribution.Fields.Field Methods fold1 :: Semigroup m => Field m -> m # foldMap1 :: Semigroup m => (a -> m) -> Field a -> m # foldMap1' :: Semigroup m => (a -> m) -> Field a -> m # toNonEmpty :: Field a -> NonEmpty a # maximum :: Ord a => Field a -> a # minimum :: Ord a => Field a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Field a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Field a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Field a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Field a -> b # | |
| Functor Field Source # | |
| Foldable Field Source # | |
Defined in Distribution.Fields.Field Methods fold :: Monoid m => Field m -> m # foldMap :: Monoid m => (a -> m) -> Field a -> m # foldMap' :: Monoid m => (a -> m) -> Field a -> m # foldr :: (a -> b -> b) -> b -> Field a -> b # foldr' :: (a -> b -> b) -> b -> Field a -> b # foldl :: (b -> a -> b) -> b -> Field a -> b # foldl' :: (b -> a -> b) -> b -> Field a -> b # foldr1 :: (a -> a -> a) -> Field a -> a # foldl1 :: (a -> a -> a) -> Field a -> a # elem :: Eq a => a -> Field a -> Bool # maximum :: Ord a => Field a -> a # minimum :: Ord a => Field a -> a # | |
| Traversable Field Source # | |
| Show ann => Show (Field ann) Source # | |
| Eq ann => Eq (Field ann) Source # | |
| Ord ann => Ord (Field ann) Source # | Since: 3.12.0.0 |
A field name.
Invariant: ByteString is lower-case ASCII.
Instances
| Foldable1 Name Source # | Since: 3.12.0.0 |
Defined in Distribution.Fields.Field Methods fold1 :: Semigroup m => Name m -> m # foldMap1 :: Semigroup m => (a -> m) -> Name a -> m # foldMap1' :: Semigroup m => (a -> m) -> Name a -> m # toNonEmpty :: Name a -> NonEmpty a # maximum :: Ord a => Name a -> a # minimum :: Ord a => Name a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Name a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Name a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Name a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Name a -> b # | |
| Functor Name Source # | |
| Foldable Name Source # | |
Defined in Distribution.Fields.Field Methods fold :: Monoid m => Name m -> m # foldMap :: Monoid m => (a -> m) -> Name a -> m # foldMap' :: Monoid m => (a -> m) -> Name a -> m # foldr :: (a -> b -> b) -> b -> Name a -> b # foldr' :: (a -> b -> b) -> b -> Name a -> b # foldl :: (b -> a -> b) -> b -> Name a -> b # foldl' :: (b -> a -> b) -> b -> Name a -> b # foldr1 :: (a -> a -> a) -> Name a -> a # foldl1 :: (a -> a -> a) -> Name a -> a # elem :: Eq a => a -> Name a -> Bool # maximum :: Ord a => Name a -> a # | |
| Traversable Name Source # | |
| Show ann => Show (Name ann) Source # | |
| Eq ann => Eq (Name ann) Source # | |
| Ord ann => Ord (Name ann) Source # | Since: 3.12.0.0 |
Defined in Distribution.Fields.Field | |
A line of text representing the value of a field from a Cabal file. A field may contain multiple lines.
Invariant: ByteString has no newlines.
Constructors
| FieldLine !ann !ByteString |
Instances
| Foldable1 FieldLine Source # | Since: 3.12.0.0 |
Defined in Distribution.Fields.Field Methods fold1 :: Semigroup m => FieldLine m -> m # foldMap1 :: Semigroup m => (a -> m) -> FieldLine a -> m # foldMap1' :: Semigroup m => (a -> m) -> FieldLine a -> m # toNonEmpty :: FieldLine a -> NonEmpty a # maximum :: Ord a => FieldLine a -> a # minimum :: Ord a => FieldLine a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> FieldLine a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> FieldLine a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> FieldLine a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> FieldLine a -> b # | |
| Functor FieldLine Source # | |
| Foldable FieldLine Source # | |
Defined in Distribution.Fields.Field Methods fold :: Monoid m => FieldLine m -> m # foldMap :: Monoid m => (a -> m) -> FieldLine a -> m # foldMap' :: Monoid m => (a -> m) -> FieldLine a -> m # foldr :: (a -> b -> b) -> b -> FieldLine a -> b # foldr' :: (a -> b -> b) -> b -> FieldLine a -> b # foldl :: (b -> a -> b) -> b -> FieldLine a -> b # foldl' :: (b -> a -> b) -> b -> FieldLine a -> b # foldr1 :: (a -> a -> a) -> FieldLine a -> a # foldl1 :: (a -> a -> a) -> FieldLine a -> a # toList :: FieldLine a -> [a] # length :: FieldLine a -> Int # elem :: Eq a => a -> FieldLine a -> Bool # maximum :: Ord a => FieldLine a -> a # minimum :: Ord a => FieldLine a -> a # | |
| Traversable FieldLine Source # | |
Defined in Distribution.Fields.Field | |
| Show ann => Show (FieldLine ann) Source # | |
| Eq ann => Eq (FieldLine ann) Source # | |
| Ord ann => Ord (FieldLine ann) Source # | Since: 3.12.0.0 |
Defined in Distribution.Fields.Field Methods compare :: FieldLine ann -> FieldLine ann -> Ordering # (<) :: FieldLine ann -> FieldLine ann -> Bool # (<=) :: FieldLine ann -> FieldLine ann -> Bool # (>) :: FieldLine ann -> FieldLine ann -> Bool # (>=) :: FieldLine ann -> FieldLine ann -> Bool # | |
data SectionArg ann Source #
Section arguments, e.g. name of the library
Constructors
| SecArgName !ann !ByteString | identifier, or something which looks like number. Also many dot numbers, i.e. "7.6.3" |
| SecArgStr !ann !ByteString | quoted string |
| SecArgOther !ann !ByteString | everything else, mm. operators (e.g. in if-section conditionals) |
Instances
type FieldName = ByteString Source #
Grammar and parsing
readFields :: ByteString -> Either ParseError [Field Position] Source #
Parse cabal style ByteString into list of Fields, i.e. the cabal AST.
readFields assumes that input ByteString is valid UTF8, specifically it doesn't validate that file is valid UTF8.
Therefore bytestrings inside returned Field will be invalid as UTF8 if the input were.
>>>readFields "foo: \223"Right [Field (Name (Position 1 1) "foo") [FieldLine (Position 1 6) "\223"]]
readFields won't (necessarily) fail on invalid UTF8 data, but the reported positions may be off.
You may get weird errors on non-UTF8 input, for example readFields will fail on latin1 encoded non-breaking space:
>>>isLeft (readFields "\xa0 foo: bar")True
That is rejected because parser thinks \xa0 is a section name,
and section arguments may not contain colon.
If there are just latin1 non-breaking spaces, they become part of the name:
>>>readFields "\xa0\&foo: bar"Right [Field (Name (Position 1 1) "\160foo") [FieldLine (Position 1 7) "bar"]]
The UTF8 non-breaking space is accepted as an indentation character (but warned about by readFields').
>>>readFields' "\xc2\xa0 foo: bar"Right ([Field (Name (Position 1 3) "foo") [FieldLine (Position 1 8) "bar"]],[LexWarning LexWarningNBSP (Position 1 1)])
readFields' :: ByteString -> Either ParseError ([Field Position], [LexWarning]) Source #
Like readFields but also return lexer warnings.
ParseResult
data ParseResult src a Source #
A monad with failure and accumulating errors and warnings.
Instances
| Applicative (ParseResult src) Source # | |
Defined in Distribution.Fields.ParseResult Methods pure :: a -> ParseResult src a # (<*>) :: ParseResult src (a -> b) -> ParseResult src a -> ParseResult src b # liftA2 :: (a -> b -> c) -> ParseResult src a -> ParseResult src b -> ParseResult src c # (*>) :: ParseResult src a -> ParseResult src b -> ParseResult src b # (<*) :: ParseResult src a -> ParseResult src b -> ParseResult src a # | |
| Functor (ParseResult src) Source # | |
Defined in Distribution.Fields.ParseResult Methods fmap :: (a -> b) -> ParseResult src a -> ParseResult src b # (<$) :: a -> ParseResult src b -> ParseResult src a # | |
| Monad (ParseResult src) Source # | |
Defined in Distribution.Fields.ParseResult Methods (>>=) :: ParseResult src a -> (a -> ParseResult src b) -> ParseResult src b # (>>) :: ParseResult src a -> ParseResult src b -> ParseResult src b # return :: a -> ParseResult src a # | |
runParseResult :: ParseResult src a -> ([PWarningWithSource src], Either (Maybe Version, NonEmpty (PErrorWithSource src)) a) Source #
Destruct a ParseResult into the emitted warnings and either
a successful value or
list of errors and possibly recovered a spec-version declaration.
parseWarning :: Position -> PWarnType -> String -> ParseResult src () Source #
Add a warning. This doesn't fail the parsing process.
parseWarnings :: [PWarning] -> ParseResult src () Source #
Add multiple warnings at once.
parseFailure :: Position -> String -> ParseResult src () Source #
Add an error, but not fail the parser yet.
For fatal failure use parseFatalFailure
parseFatalFailure :: Position -> String -> ParseResult src a Source #
Add an fatal error.
Warnings
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 |
|
| PWTVersionTag | there are version with tags |
| PWTNewSyntax | New syntax used, but no |
| PWTOldSyntax | Old syntax used, and |
| 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 "" |
| PWTInconsistentIndentation | sections contents (sections and fields) are indented inconsistently |
| PWTExperimental | Experimental feature |
Instances
| Binary PWarnType Source # | |||||
| NFData PWarnType Source # | |||||
Defined in Distribution.Parsec.Warning | |||||
| Bounded PWarnType Source # | |||||
| Enum PWarnType Source # | |||||
Defined in Distribution.Parsec.Warning Methods succ :: PWarnType -> PWarnType # pred :: PWarnType -> PWarnType # fromEnum :: PWarnType -> Int # enumFrom :: PWarnType -> [PWarnType] # enumFromThen :: PWarnType -> PWarnType -> [PWarnType] # enumFromTo :: PWarnType -> PWarnType -> [PWarnType] # enumFromThenTo :: PWarnType -> PWarnType -> PWarnType -> [PWarnType] # | |||||
| Generic PWarnType Source # | |||||
Defined in Distribution.Parsec.Warning Associated Types
| |||||
| Show PWarnType Source # | |||||
| Eq PWarnType Source # | |||||
| Ord PWarnType Source # | |||||
| type Rep PWarnType Source # | |||||
Defined in Distribution.Parsec.Warning type Rep PWarnType = D1 ('MetaData "PWarnType" "Distribution.Parsec.Warning" "Cabal-syntax-3.18.1.0-inplace" '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 "PWTInconsistentIndentation" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PWTExperimental" 'PrefixI 'False) (U1 :: Type -> Type)))))) | |||||
Parser warning.
Constructors
| PWarning | |
Fields
| |
Instances
data PWarningWithSource src Source #
Constructors
| PWarningWithSource | |
Fields
| |
Instances
| Functor PWarningWithSource Source # | |||||
Defined in Distribution.Parsec.Warning Methods fmap :: (a -> b) -> PWarningWithSource a -> PWarningWithSource b # (<$) :: a -> PWarningWithSource b -> PWarningWithSource a # | |||||
| Generic (PWarningWithSource src) Source # | |||||
Defined in Distribution.Parsec.Warning Associated Types
Methods from :: PWarningWithSource src -> Rep (PWarningWithSource src) x # to :: Rep (PWarningWithSource src) x -> PWarningWithSource src # | |||||
| Show src => Show (PWarningWithSource src) Source # | |||||
Defined in Distribution.Parsec.Warning Methods showsPrec :: Int -> PWarningWithSource src -> ShowS # show :: PWarningWithSource src -> String # showList :: [PWarningWithSource src] -> ShowS # | |||||
| Eq src => Eq (PWarningWithSource src) Source # | |||||
Defined in Distribution.Parsec.Warning Methods (==) :: PWarningWithSource src -> PWarningWithSource src -> Bool # (/=) :: PWarningWithSource src -> PWarningWithSource src -> Bool # | |||||
| Ord src => Ord (PWarningWithSource src) Source # | |||||
Defined in Distribution.Parsec.Warning Methods compare :: PWarningWithSource src -> PWarningWithSource src -> Ordering # (<) :: PWarningWithSource src -> PWarningWithSource src -> Bool # (<=) :: PWarningWithSource src -> PWarningWithSource src -> Bool # (>) :: PWarningWithSource src -> PWarningWithSource src -> Bool # (>=) :: PWarningWithSource src -> PWarningWithSource src -> Bool # max :: PWarningWithSource src -> PWarningWithSource src -> PWarningWithSource src # min :: PWarningWithSource src -> PWarningWithSource src -> PWarningWithSource src # | |||||
| type Rep (PWarningWithSource src) Source # | |||||
Defined in Distribution.Parsec.Warning type Rep (PWarningWithSource src) = D1 ('MetaData "PWarningWithSource" "Distribution.Parsec.Warning" "Cabal-syntax-3.18.1.0-inplace" 'False) (C1 ('MetaCons "PWarningWithSource" 'PrefixI 'True) (S1 ('MetaSel ('Just "pwarningSource") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PSource src)) :*: S1 ('MetaSel ('Just "pwarning") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PWarning))) | |||||
The source of a parse error
Constructors
| PKnownSource src | |
| PUnknownSource |
Instances
| Functor PSource Source # | |||||
| Binary src => Binary (PSource src) Source # | |||||
| NFData src => NFData (PSource src) Source # | |||||
Defined in Distribution.Parsec.Source | |||||
| Generic (PSource src) Source # | |||||
Defined in Distribution.Parsec.Source Associated Types
| |||||
| Show src => Show (PSource src) Source # | |||||
| Eq src => Eq (PSource src) Source # | |||||
| Ord src => Ord (PSource src) Source # | |||||
Defined in Distribution.Parsec.Source | |||||
| type Rep (PSource src) Source # | |||||
Defined in Distribution.Parsec.Source type Rep (PSource src) = D1 ('MetaData "PSource" "Distribution.Parsec.Source" "Cabal-syntax-3.18.1.0-inplace" 'False) (C1 ('MetaCons "PKnownSource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 src)) :+: C1 ('MetaCons "PUnknownSource" 'PrefixI 'False) (U1 :: Type -> Type)) | |||||
Errors
Parser error.
Constructors
| PError | |
Fields | |
Instances
| Binary PError Source # | |||||
| NFData PError Source # | |||||
Defined in Distribution.Parsec.Error | |||||
| Generic PError Source # | |||||
Defined in Distribution.Parsec.Error Associated Types
| |||||
| Show PError Source # | |||||
| type Rep PError Source # | |||||
Defined in Distribution.Parsec.Error type Rep PError = D1 ('MetaData "PError" "Distribution.Parsec.Error" "Cabal-syntax-3.18.1.0-inplace" 'False) (C1 ('MetaCons "PError" 'PrefixI 'True) (S1 ('MetaSel ('Just "perrorPosition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Position) :*: S1 ('MetaSel ('Just "perrorMessage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) | |||||
data PErrorWithSource src Source #
Constructors
| PErrorWithSource | |
Fields
| |
Instances
| Functor PErrorWithSource Source # | |||||
Defined in Distribution.Parsec.Error Methods fmap :: (a -> b) -> PErrorWithSource a -> PErrorWithSource b # (<$) :: a -> PErrorWithSource b -> PErrorWithSource a # | |||||
| Generic (PErrorWithSource src) Source # | |||||
Defined in Distribution.Parsec.Error Associated Types
Methods from :: PErrorWithSource src -> Rep (PErrorWithSource src) x # to :: Rep (PErrorWithSource src) x -> PErrorWithSource src # | |||||
| Show src => Show (PErrorWithSource src) Source # | |||||
Defined in Distribution.Parsec.Error Methods showsPrec :: Int -> PErrorWithSource src -> ShowS # show :: PErrorWithSource src -> String # showList :: [PErrorWithSource src] -> ShowS # | |||||
| type Rep (PErrorWithSource src) Source # | |||||
Defined in Distribution.Parsec.Error type Rep (PErrorWithSource src) = D1 ('MetaData "PErrorWithSource" "Distribution.Parsec.Error" "Cabal-syntax-3.18.1.0-inplace" 'False) (C1 ('MetaCons "PErrorWithSource" 'PrefixI 'True) (S1 ('MetaSel ('Just "perrorSource") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PSource src)) :*: S1 ('MetaSel ('Just "perror") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PError))) | |||||
Pretty printing
data CommentPosition Source #
This type is used to discern when a comment block should go
before or after a cabal-like file field, otherwise it would
be hardcoded to a single position. It is often used in
conjunction with PrettyField.
Constructors
| CommentBefore [String] | |
| CommentAfter [String] | |
| NoComment |
data PrettyField ann Source #
Constructors
| PrettyField ann FieldName Doc | |
| PrettySection ann FieldName [Doc] [PrettyField ann] | |
| PrettyEmpty |
Instances
| Functor PrettyField Source # | |
Defined in Distribution.Fields.Pretty Methods fmap :: (a -> b) -> PrettyField a -> PrettyField b # (<$) :: a -> PrettyField b -> PrettyField a # | |
| Foldable PrettyField Source # | |
Defined in Distribution.Fields.Pretty Methods fold :: Monoid m => PrettyField m -> m # foldMap :: Monoid m => (a -> m) -> PrettyField a -> m # foldMap' :: Monoid m => (a -> m) -> PrettyField a -> m # foldr :: (a -> b -> b) -> b -> PrettyField a -> b # foldr' :: (a -> b -> b) -> b -> PrettyField a -> b # foldl :: (b -> a -> b) -> b -> PrettyField a -> b # foldl' :: (b -> a -> b) -> b -> PrettyField a -> b # foldr1 :: (a -> a -> a) -> PrettyField a -> a # foldl1 :: (a -> a -> a) -> PrettyField a -> a # toList :: PrettyField a -> [a] # null :: PrettyField a -> Bool # length :: PrettyField a -> Int # elem :: Eq a => a -> PrettyField a -> Bool # maximum :: Ord a => PrettyField a -> a # minimum :: Ord a => PrettyField a -> a # sum :: Num a => PrettyField a -> a # product :: Num a => PrettyField a -> a # | |
| Traversable PrettyField Source # | |
Defined in Distribution.Fields.Pretty Methods traverse :: Applicative f => (a -> f b) -> PrettyField a -> f (PrettyField b) # sequenceA :: Applicative f => PrettyField (f a) -> f (PrettyField a) # mapM :: Monad m => (a -> m b) -> PrettyField a -> m (PrettyField b) # sequence :: Monad m => PrettyField (m a) -> m (PrettyField a) # | |
showFields :: (ann -> CommentPosition) -> [PrettyField ann] -> String Source #
Prettyprint a list of fields.
Note: the first argument should return Strings without newlines
and properly prefixes (with --) to count as comments.
This unsafety is left in place so one could generate empty lines
between comment lines.
Transformation from Field
genericFromParsecFields Source #
Arguments
| :: Applicative f | |
| => (FieldName -> [FieldLine ann] -> f Doc) | transform field contents |
| -> (FieldName -> [SectionArg ann] -> f [Doc]) | transform section arguments |
| -> [Field ann] | |
| -> f [PrettyField ann] |
fromParsecFields :: [Field ann] -> [PrettyField ann] Source #
Simple variant of genericFromParsecField