| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Distribution.Fields.Pretty
Contents
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.
Constructors
| CommentBefore [String] | |
| CommentAfter [String] | |
| NoComment |
data PrettyField ann Source #
Constructors
| PrettyField ann FieldName Doc | |
| PrettySection ann FieldName [Doc] [PrettyField ann] | |
| PrettyEmpty |
Instances
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.
Arguments
| :: (ann -> CommentPosition) | Convert an annotation to lined to preceed the field or section. |
| -> (ann -> [String] -> [String]) | Post-process non-annotation produced lines. |
| -> Int | Indentation level. |
| -> [PrettyField ann] | Fields/sections to show. |
| -> String |
showFields with user specified indentation.
Transformation from Field
fromParsecFields :: [Field ann] -> [PrettyField ann] Source #
Simple variant of genericFromParsecField
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] |
prettyFieldLines :: FieldName -> [FieldLine ann] -> Doc Source #
Used in fromParsecFields.
prettySectionArgs :: FieldName -> [SectionArg ann] -> [Doc] Source #
Used in fromParsecFields.