@@ -14,6 +14,7 @@ where
1414import BasicTypes
1515import BooleanFormula
1616import Control.Monad
17+import Data.Bool (bool)
1718import GHC
1819import Ormolu.Printer.Combinators
1920import Ormolu.Printer.Meat.Common
@@ -22,7 +23,7 @@ import Ormolu.Utils
2223
2324p_sigDecl :: Sig GhcPs -> R ()
2425p_sigDecl = \case
25− TypeSig NoExt names hswc -> p_typeSig names hswc
26+ TypeSig NoExt names hswc -> p_typeSig True names hswc
2627 PatSynSig NoExt names hsib -> p_patSynSig names hsib
2728 ClassOpSig NoExt def names hsib -> p_classOpSig def names hsib
2829 FixSig NoExt sig -> p_fixSig sig
@@ -35,15 +36,16 @@ p_sigDecl = \case
3536 _ -> notImplemented "certain types of signature declarations"
3637
3738p_typeSig
38− :: [Located RdrName] -- ^ Names (before @::@)
39+ :: Bool -- ^ Should the tail of the names be indented
40+ -> [Located RdrName] -- ^ Names (before @::@)
3941 -> LHsSigWcType GhcPs -- ^ Type
4042 -> R ()
41−p_typeSig [] _ = return () -- should not happen though
42−p_typeSig (n:ns) hswc = do
43+p_typeSig _ [] _ = return () -- should not happen though
44+p_typeSig indentTail (n:ns) hswc = do
4345 p_rdrName n
4446 if null ns
4547 then p_typeAscription hswc
46− else inci $ do
48+ else bool id inci indentTail $ do
4749 comma
4850 breakpoint
4951 sep (comma >> breakpoint) p_rdrName ns
@@ -65,8 +67,11 @@ p_patSynSig
6567 -> HsImplicitBndrs GhcPs (LHsType GhcPs)
6668 -> R ()
6769p_patSynSig names hsib = do
68− txt "pattern "
69− p_typeSig names HsWC {hswc_ext = NoExt, hswc_body = hsib}
70+ txt "pattern"
71+ let body = p_typeSig False names HsWC {hswc_ext = NoExt, hswc_body = hsib}
72+ if length names > 1
73+ then breakpoint >> inci body
74+ else space >> body
7075
7176p_classOpSig
7277 :: Bool -- ^ Whether this is a \"default\" signature
@@ -75,7 +80,7 @@ p_classOpSig
7580 -> R ()
7681p_classOpSig def names hsib = do
7782 when def (txt "default" >> space)
78− p_typeSig names HsWC {hswc_ext = NoExt, hswc_body = hsib}
83+ p_typeSig True names HsWC {hswc_ext = NoExt, hswc_body = hsib}
7984
8085p_fixSig
8186 :: FixitySig GhcPs