Skip to content

Commit 07d37fd

Browse files
committed
Extract helper printing functions
1 parent 7affa17 commit 07d37fd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/Language/Haskell/Stylish/Step/Signature.hs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,21 @@ formatSignatureDecl cfg@Config{..} m ldecl = do
7272
Block (getStartLineUnsafe ldecl) (getEndLineUnsafe ldecl)
7373

7474
printDecl :: Config -> Module -> Located SignatureDecl -> Lines
75-
printDecl Config{..} m ldecl@(L _declPos decl) = runPrinter_ printerConfig [] m do
76-
(putRdrName $ sigName decl) >> space >> putText "::" >> newline
77-
spaces 5 >> (putRdrName $ head $ sigParameters decl) >> newline
78-
traverse (\para -> spaces 2 >> putText "->" >> space >> (putRdrName para) >> newline) (tail $ sigParameters decl)
75+
printDecl Config{..} m (L _declPos decl) = runPrinter_ printerConfig [] m do
76+
printFirstLine
77+
printSecondLine
78+
printRemainingLines
7979
where
80+
81+
printFirstLine =
82+
(putRdrName $ sigName decl) >> space >> putText "::" >> newline
83+
84+
printSecondLine =
85+
spaces 5 >> (putRdrName $ head $ sigParameters decl) >> newline
86+
87+
printRemainingLines =
88+
traverse (\para -> spaces 2 >> putText "->" >> space >> (putRdrName para) >> newline) (tail $ sigParameters decl)
89+
8090
printerConfig = PrinterConfig
8191
{ columns = case cMaxColumns of
8292
NoMaxColumns -> Nothing

0 commit comments

Comments
 (0)