on master help sign in
Add ‘pragmaBraces’
d9d4219mrkkrp
src/Ormolu/Printer/Combinators.hs+10
@@ -37,6 +37,7 @@ module Ormolu.Printer.Combinators
37 , bracketsPar
37 , bracketsPar
38 , parens
38 , parens
39 , parensHash
39 , parensHash
40+ , pragmaBraces
40 -- ** Literals
41 -- ** Literals
41 , comma
42 , comma
42 , space
43 , space
@@ -260,6 +261,15 @@ parensHash m = sitcc $ do
260 breakpoint
261 breakpoint
261 txt "#)"
262 txt "#)"
262
263
264+-- | Braces as used for pragmas: @{-#@ and @#-}@.
265+
266+pragmaBraces :: R () -> R ()
267+pragmaBraces m = sitcc $ do
268+ txt "{-# "
269+ m
270+ vlayout space (newline >> txt " ")
271+ txt "#-}"
272+
263-- | Surround given entity by optional space before and a newline after, iff
273-- | Surround given entity by optional space before and a newline after, iff
264-- current layout is multiline.
274-- current layout is multiline.
265
275
src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−3
@@ -69,8 +69,7 @@ p_inlineSig
69 :: Located RdrName -- ^ Name
69 :: Located RdrName -- ^ Name
70 -> InlinePragma -- ^ Inline pragma specification
70 -> InlinePragma -- ^ Inline pragma specification
71 -> R ()
71 -> R ()
72−p_inlineSig name InlinePragma {..} = do
72+p_inlineSig name InlinePragma {..} = pragmaBraces $ do
73− txt "{-# "
74 txt $ case inl_inline of
73 txt $ case inl_inline of
75 Inline -> "INLINE"
74 Inline -> "INLINE"
76 Inlinable -> "INLINEABLE"
75 Inlinable -> "INLINEABLE"
@@ -87,4 +86,3 @@ p_inlineSig name InlinePragma {..} = do
87 brackets (atom n)
86 brackets (atom n)
88 space
87 space
89 p_rdrName name
88 p_rdrName name
90− txt " #-}"