Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ormolu.Parser.CommentStream
Contents
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
Eq CommentStream Source # | |
Defined in Ormolu.Parser.CommentStream Methods (==) :: CommentStream -> CommentStream -> Bool # (/=) :: CommentStream -> CommentStream -> Bool # | |
Data CommentStream Source # | |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CommentStream toConstr :: CommentStream -> Constr dataTypeOf :: CommentStream -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CommentStream) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CommentStream) gmapT :: (forall b. Data b => b -> b) -> CommentStream -> CommentStream gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CommentStream -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CommentStream -> r gmapQ :: (forall d. Data d => d -> u) -> CommentStream -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> CommentStream -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CommentStream -> m CommentStream | |
Semigroup CommentStream Source # | |
Defined in Ormolu.Parser.CommentStream Methods (<>) :: CommentStream -> CommentStream -> CommentStream sconcat :: NonEmpty CommentStream -> CommentStream stimes :: Integral b => b -> CommentStream -> CommentStream | |
Monoid CommentStream Source # | |
Defined in Ormolu.Parser.CommentStream Methods mempty :: CommentStream # mappend :: CommentStream -> CommentStream -> CommentStream # mconcat :: [CommentStream] -> CommentStream # |
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
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.
Instances
Eq Comment Source # | |
Data Comment Source # | |
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 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Comment dataTypeOf :: Comment -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Comment) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comment) gmapT :: (forall b. Data b => b -> b) -> Comment -> Comment gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r gmapQ :: (forall d. Data d => d -> u) -> Comment -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Comment -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Comment -> m Comment gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment | |
Show Comment Source # | |
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?