| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Distribution.Fields.Pretty
Description
Cabal-like file AST types: Field, Section etc,
This (intermediate) data type is used for pretty-printing.
Since: 3.0.0.0
Synopsis
- 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
- showFields' :: (ann -> CommentPosition) -> (ann -> [String] -> [String]) -> Int -> [PrettyField ann] -> String
- fromParsecFields :: [Field ann] -> [PrettyField ann]
- genericFromParsecFields :: Applicative f => (FieldName -> [FieldLine ann] -> f Doc) -> (FieldName -> [SectionArg ann] -> f [Doc]) -> [Field ann] -> f [PrettyField ann]
- prettyFieldLines :: FieldName -> [FieldLine ann] -> Doc
- prettySectionArgs :: FieldName -> [SectionArg ann] -> [Doc]
Fields
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.
data PrettyField ann Source #
Constructors
Instances
Instances details
Instance details
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 #
Instance details
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) #
Instance details
Defined in Distribution.Fields.Pretty
Methods
fmap :: (a -> b) -> PrettyField a -> PrettyField b #
(<$) :: a -> PrettyField b -> PrettyField a #
showFields :: (ann -> CommentPosition) -> [PrettyField ann] -> String Source #
Prettyprint a list of fields.
Note: the first argument should return String s 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.
Arguments
Convert an annotation to lined to precede the field or section.
Indentation level.
Fields/sections to show.
showFields with user specified indentation.
Transformation from Field
fromParsecFields :: [Field ann] -> [PrettyField ann] Source #
Simple variant of genericFromParsecField
prettyFieldLines :: FieldName -> [FieldLine ann] -> Doc Source #
Used in fromParsecFields .
prettySectionArgs :: FieldName -> [SectionArg ann] -> [Doc] Source #
Used in fromParsecFields .