ormolu-0.1.2.0: A formatter for Haskell source code

Safe Haskell | None
Language | Haskell2010

Ormolu.Parser.CommentStream

Contents

- Comment stream
- Comment

Description

Functions for working with comment stream.

Synopsis

- newtype CommentStream = CommentStream [RealLocated Comment]
- mkCommentStream :: String -> [Located String] -> PState -> (Maybe (RealLocated Comment), [Shebang], [([RealLocated Comment], Pragma)], CommentStream)
- showCommentStream :: CommentStream -> String
- data Comment = Comment Bool (NonEmpty String)
- unComment :: Comment -> NonEmpty String
- hasAtomsBefore :: Comment -> Bool
- isMultilineComment :: Comment -> Bool

# Comment stream

newtype CommentStream Source #

A stream of `RealLocated` `Comment`s in ascending order with respect to beginning of corresponding spans.

Constructors

CommentStream [RealLocated Comment] |

#### Instances

Instances details

Eq CommentStream Source # |
Instance details Defined in Ormolu.Parser.CommentStream Methods (==) :: CommentStream -> CommentStream -> Bool Source # (/=) :: CommentStream -> CommentStream -> Bool Source #
Data CommentStream Source # |

Instance details

Defined in Ormolu.Parser.CommentStream

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CommentStream -> c CommentStream Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CommentStream Source #

toConstr :: CommentStream -> Constr Source #

dataTypeOf :: CommentStream -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CommentStream) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CommentStream) Source #

gmapT :: (forall b. Data b => b -> b) -> CommentStream -> CommentStream Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CommentStream -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CommentStream -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CommentStream -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CommentStream -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream Source #

Semigroup CommentStream Source # |
Instance details Defined in Ormolu.Parser.CommentStream Methods (<>) :: CommentStream -> CommentStream -> CommentStream Source # sconcat :: NonEmpty CommentStream -> CommentStream Source # stimes :: Integral b => b -> CommentStream -> CommentStream Source #
Monoid CommentStream Source # |
Instance details Defined in Ormolu.Parser.CommentStream Methods mempty :: CommentStream Source # mappend :: CommentStream -> CommentStream -> CommentStream Source # mconcat :: [CommentStream] -> CommentStream Source #

mkCommentStream Source #

Arguments

:: String | Original input
-> [Located String] | Extra comments to include
-> PState | Parser state to use for comment extraction
-> (Maybe (RealLocated Comment), [Shebang], [([RealLocated Comment], Pragma)], CommentStream) | Stack header, shebangs, pragmas, and comment stream

Create `CommentStream` from `PState`. The pragmas and shebangs are removed from the `CommentStream`. Shebangs are only extracted from the comments that come from the first argument.

showCommentStream :: CommentStream -> String Source #

Pretty-print a `CommentStream`.

# Comment

data Comment Source #

A wrapper for a single comment. The `Bool` indicates whether there were atoms before beginning of the comment in the original input. The `NonEmpty` list inside contains lines of multiline comment `{- … -}` or just single item/line otherwise.

Constructors

Comment Bool (NonEmpty String) |

#### Instances

Instances details

Eq Comment Source # |
Instance details Defined in Ormolu.Parser.CommentStream Methods (==) :: Comment -> Comment -> Bool Source # (/=) :: Comment -> Comment -> Bool Source #
Data Comment Source # |

Instance details

Defined in Ormolu.Parser.CommentStream

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Comment -> c Comment Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Comment Source #

toConstr :: Comment -> Constr Source #

dataTypeOf :: Comment -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Comment) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comment) Source #

gmapT :: (forall b. Data b => b -> b) -> Comment -> Comment Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Comment -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Comment -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Comment -> m Comment Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment Source #

Show Comment Source # |
Instance details Defined in Ormolu.Parser.CommentStream Methods showsPrec :: Int -> Comment -> ShowS Source # show :: Comment -> String Source # showList :: [Comment] -> ShowS Source #

unComment :: Comment -> NonEmpty String Source #

Get a collection of lines from a `Comment`.

hasAtomsBefore :: Comment -> Bool Source #

Check whether the `Comment` had some non-whitespace atoms in front of it in the original input.

isMultilineComment :: Comment -> Bool Source #

Is this comment multiline-style?