on master help sign in
Add ‘pragmaBraces’
commitd9d4219f83db2fe93008c0de5031b83ee596c4e7 authormrkkrp <mark.karpov@tweag.io> dateSun 9 Jun 2019, 14:26 (7 years ago) parentc421b22
2 files changed+11−3
src/Ormolu/Printer/Combinators.hs+10 src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−3
src/Ormolu/Printer/Combinators.hs+10
@@ -37,6 +37,7 @@ module Ormolu.Printer.Combinators
3737 , bracketsPar
3838 , parens
3939 , parensHash
40+ , pragmaBraces
4041 -- ** Literals
4142 , comma
4243 , space
@@ -260,6 +261,15 @@ parensHash m = sitcc $ do
260261 breakpoint
261262 txt "#)"
262263
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+
263273-- | Surround given entity by optional space before and a newline after, iff
264274-- current layout is multiline.
265275
src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−3
@@ -69,8 +69,7 @@ p_inlineSig
6969 :: Located RdrName -- ^ Name
7070 -> InlinePragma -- ^ Inline pragma specification
7171 -> R ()
72−p_inlineSig name InlinePragma {..} = do
73− txt "{-# "
72+p_inlineSig name InlinePragma {..} = pragmaBraces $ do
7473 txt $ case inl_inline of
7574 Inline -> "INLINE"
7675 Inlinable -> "INLINEABLE"
@@ -87,4 +86,3 @@ p_inlineSig name InlinePragma {..} = do
8786 brackets (atom n)
8887 space
8988 p_rdrName name
90− txt " #-}"