@@ -54,7 +54,7 @@ p_valDecl = line . p_valDecl'
54p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
54p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
55p_valDecl' = \case
55p_valDecl' = \case
56 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
56 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
57− PatBind NoExt pat grhss _ -> p_match PatternBind [pat] grhss
57+ PatBind NoExt pat grhss _ -> p_match PatternBind False [pat] grhss
58 VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
58 VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
59 AbsBinds {} -> notImplemented "AbsBinds" -- introduced by the type checker
59 AbsBinds {} -> notImplemented "AbsBinds" -- introduced by the type checker
60 PatSynBind NoExt psb -> p_patSynBind psb
60 PatSynBind NoExt psb -> p_patSynBind psb
@@ -73,18 +73,17 @@ p_matchGroup
74p_matchGroup style MG {..} =
74p_matchGroup style MG {..} =
75 locatedVia Nothing mg_alts $
75 locatedVia Nothing mg_alts $
76− newlineSep (located' (\Match {..} -> p_match style m_pats m_grhss))
76+ newlineSep (located' (\m@Match {..} ->
77+ p_match style (isInfixMatch m) m_pats m_grhss))
77p_matchGroup _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
78p_matchGroup _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
80 :: MatchGroupStyle
81 :: MatchGroupStyle
82+ -> Bool -- ^ Is this an infix match?
81 -> [LPat GhcPs]
83 -> [LPat GhcPs]
82 -> GRHSs GhcPs (LHsExpr GhcPs)
84 -> GRHSs GhcPs (LHsExpr GhcPs)
84−p_match style m_pats m_grhss = do
86+p_match style isInfix m_pats m_grhss = do
86− Function name -> p_rdrName name
88 -- NOTE Normally, since patterns may be placed in a multi-line layout, it
87 -- NOTE Normally, since patterns may be placed in a multi-line layout, it
89 -- is necessary to bump indentation for the pattern group so it's more
88 -- is necessary to bump indentation for the pattern group so it's more
90 -- indented than function name. This in turn means that indentation for
89 -- indented than function name. This in turn means that indentation for
@@ -93,7 +92,9 @@ p_match style m_pats m_grhss = do
93 -- need to be a bit more clever here and bump indentation level only when
92 -- need to be a bit more clever here and bump indentation level only when
94 -- pattern group is multiline.
93 -- pattern group is multiline.
95 inci' <- case NE.nonEmpty m_pats of
94 inci' <- case NE.nonEmpty m_pats of
96− Nothing -> return id
95+ Nothing -> id <$ case style of
96+ Function name -> p_rdrName name
97 Just ne_pats -> do
98 Just ne_pats -> do
98 let combinedSpans = combineSrcSpans' $
99 let combinedSpans = combineSrcSpans' $
99 getSpan <$> ne_pats
100 getSpan <$> ne_pats
@@ -101,16 +102,20 @@ p_match style m_pats m_grhss = do
102 else inci
103 else inci
103 switchLayout combinedSpans $ do
104 switchLayout combinedSpans $ do
105+ let stdCase = velt' (located' p_pat <$> m_pats)
104 case style of
106 case style of
105− Function _ -> breakpoint
107+ Function name ->
106− PatternBind -> return ()
108+ p_infixDefHelper
107− Case -> return ()
109+ isInfix
109− LambdaCase -> return ()
110− let wrapper = case style of
111− Function _ -> inci'
110+ inci'
112− _ -> id
111+ (p_rdrName name)
113− wrapper (velt' (located' p_pat <$> m_pats))
112+ (located' p_pat <$> m_pats)
113+ PatternBind -> stdCase
118+ LambdaCase -> stdCase
114 return inci'
119 return inci'
115 inci' $ do
120 inci' $ do
116 let GRHSs {..} = m_grhss
121 let GRHSs {..} = m_grhss