@@ -15,15 +15,15 @@ module Ormolu.Printer.Combinators
17 , relaxComments
17 , relaxComments
20 , locatedVia
19 , locatedVia
21 , located'
20 , located'
22 , switchLayout
21 , switchLayout
26 , breakpoint
23 , breakpoint
24+ -- ** Formatting lists
28 , spaceSep
28 , spaceSep
29 , newlineSep
29 , newlineSep
@@ -66,7 +66,7 @@ txt t = ensureIndent >> spit t
66atom :: Outputable a => a -> R ()
66atom :: Outputable a => a -> R ()
67atom = txt . T.pack . showSDocUnsafe . ppr
67atom = txt . T.pack . showSDocUnsafe . ppr
69−-- | Enter a 'Located' entity. This primitive handles outputting comments
69+-- | Enter a 'Located' entity. This combinator handles outputting comments
70-- that may be associated with the primitive and sets corresponding layout
70-- that may be associated with the primitive and sets corresponding layout
71-- for the inner computation.
71-- for the inner computation.
@@ -77,7 +77,7 @@ located
78located loc@(L l _) = locatedVia (Just l) loc
78located loc@(L l _) = locatedVia (Just l) loc
80−-- | A special version of 'located' that allows to control layout using
80+-- | A special version of 'located' that allows to control layout using an
81-- externally provided span. 'Nothing' means that layout won't be changed.
81-- externally provided span. 'Nothing' means that layout won't be changed.
@@ -129,6 +129,15 @@ switchLayout spn = enterLayout
129 then SingleLine
129 then SingleLine
130 else MultiLine)
130 else MultiLine)
132+-- | Insert a space if enclosing layout is single-line, or newline if it's
136+breakpoint = vlayout space newline
138+----------------------------------------------------------------------------
132-- | Element of variable layout. This means that the sub-components may be
141-- | Element of variable layout. This means that the sub-components may be
133-- rendered either on single line or each on its own line depending on
142-- rendered either on single line or each on its own line depending on
134-- current layout.
143-- current layout.
@@ -151,12 +160,6 @@ velt' xs = sitcc $ sequence_ (intersperse sep (sitcc <$> xs))
152 sep = vlayout (spit " ") newline
161 sep = vlayout (spit " ") newline
154−-- | Insert a space if enclosing layout is single-line, or newline if it's
158−breakpoint = vlayout space newline
160-- | Put separator between renderings of items of a list.
163-- | Put separator between renderings of items of a list.
@@ -199,9 +202,12 @@ line m = do
199-- | Surround given entity by backticks.
202-- | Surround given entity by backticks.
201backticks :: R () -> R ()
204backticks :: R () -> R ()
202−backticks m = txt "`" >> m >> txt "`"
205+backticks m = do
204−-- | Surround given entity by curly braces.
210+-- | Surround given entity by curly braces @{@ and @}@.
206braces :: R () -> R ()
212braces :: R () -> R ()
207braces m = sitcc $ do
213braces m = sitcc $ do
@@ -209,7 +215,7 @@ braces m = sitcc $ do
209 ospaces m
215 ospaces m
212−-- | Surround given entity by square brackets.
218+-- | Surround given entity by square brackets @[@ and @]@.
214brackets :: R () -> R ()
220brackets :: R () -> R ()
215brackets m = sitcc $ do
221brackets m = sitcc $ do
@@ -217,7 +223,7 @@ brackets m = sitcc $ do
217 ospaces m
223 ospaces m
220−-- | Surround given entity by parallel array brackets @[:@ ond @:]@.
226+-- | Surround given entity by parallel array brackets @[:@ and @:]@.
222bracketsPar :: R () -> R ()
228bracketsPar :: R () -> R ()
223bracketsPar m = sitcc $ do
229bracketsPar m = sitcc $ do
@@ -225,7 +231,7 @@ bracketsPar m = sitcc $ do
228−-- | Surround given entity by parentheses.
234+-- | Surround given entity by parentheses @(@ and @)@.
230parens :: R () -> R ()
236parens :: R () -> R ()
231parens m = sitcc $ do
237parens m = sitcc $ do