cabal-fmt-0.1.12: Format .cabal files

Copyright | Oleg Grenrus
License | GPL-3.0-or-later
Safe Haskell | None
Language | Haskell2010

CabalFmt.Comments

Description

Synopsis

- newtype Comments = Comments [ByteString]
- unComments :: Comments -> [ByteString]
- nullComments :: Comments -> Bool
- attachComments :: ByteString -> [Field Position] -> ([Field (Position, Comments)], Comments)
- overAnn :: (FieldPath -> a -> b) -> (a -> b) -> [Field a] -> [Field b]
- extractComments :: ByteString -> [(Int, Comments)]
- data FieldPath
  - = End
  - | Nth Int FieldPath
- fieldPathSize :: FieldPath -> Int
- fieldUniverseN :: [Field ann] -> [(FieldPath, Field ann)]
- fieldUniverse :: Field ann -> [(FieldPath, Field ann)]
- findPath :: (a -> Position) -> Int -> [(FieldPath, a)] -> Maybe FieldPath

# Documentation

newtype Comments #

Constructors

Comments [ByteString] |

#### Instances

Instances details

Monoid Comments # |
Instance details Defined in CabalFmt.Comments Methods mempty :: Comments # mappend :: Comments -> Comments -> Comments # mconcat :: [Comments] -> Comments #
Semigroup Comments # |
Instance details Defined in CabalFmt.Comments Methods (<>) :: Comments -> Comments -> Comments # sconcat :: NonEmpty Comments -> Comments # stimes :: Integral b => b -> Comments -> Comments #
Show Comments # |
Instance details Defined in CabalFmt.Comments Methods showsPrec :: Int -> Comments -> ShowS # show :: Comments -> String # showList :: [Comments] -> ShowS #

unComments :: Comments -> [ByteString] #

nullComments :: Comments -> Bool #

attachComments #

Arguments

:: ByteString | source with comments
-> [Field Position] | parsed source fields
-> ([Field (Position, Comments)], Comments) |

Returns a `Field` forest with comments attached.

- Comments are attached to the field after it.
- A glitch: comments "inside" the field are attached to the field after it.
- End-of-file comments are returned separately.

overAnn :: (FieldPath -> a -> b) -> (a -> b) -> [Field a] -> [Field b] #

extractComments :: ByteString -> [(Int, Comments)] #

data FieldPath #

Paths input paths. Essentially a list of offsets. Own type ofr safety.

Constructors

End |
Nth Int FieldPath |

#### Instances

Instances details

Show FieldPath # |
Instance details Defined in CabalFmt.Comments Methods showsPrec :: Int -> FieldPath -> ShowS # show :: FieldPath -> String # showList :: [FieldPath] -> ShowS #
Eq FieldPath # |
Instance details Defined in CabalFmt.Comments Methods (==) :: FieldPath -> FieldPath -> Bool # (/=) :: FieldPath -> FieldPath -> Bool #
Ord FieldPath # |
Instance details Defined in CabalFmt.Comments Methods compare :: FieldPath -> FieldPath -> Ordering # (<) :: FieldPath -> FieldPath -> Bool # (<=) :: FieldPath -> FieldPath -> Bool # (>) :: FieldPath -> FieldPath -> Bool # (>=) :: FieldPath -> FieldPath -> Bool # max :: FieldPath -> FieldPath -> FieldPath # min :: FieldPath -> FieldPath -> FieldPath #

fieldPathSize :: FieldPath -> Int #

fieldUniverseN :: [Field ann] -> [(FieldPath, Field ann)] #

fieldUniverse :: Field ann -> [(FieldPath, Field ann)] #

findPath :: (a -> Position) -> Int -> [(FieldPath, a)] -> Maybe FieldPath #