@@ -26,17 +26,22 @@ p_valDecl = line . p_valDecl'
26p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
26p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
27p_valDecl' = \case
27p_valDecl' = \case
28 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
28 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
29− _ -> notImplemented "certain kinds of binding declarations"
29+ PatBind NoExt pat grhss _ -> p_match PatternBind [pat] grhss
30+ VarBind {} -> error "VarBinds are introduced by the type checker"
31+ AbsBinds {} -> error "AbsBinds are introduced by the type checker"
32+ PatSynBind NoExt psb -> p_patSynBind psb
33+ XHsBindsLR NoExt -> notImplemented "XHsBindsLR"
32− :: Located RdrName -- ^
36+ :: Located RdrName
33− -> MatchGroup GhcPs (LHsExpr GhcPs) -- ^
37+ -> MatchGroup GhcPs (LHsExpr GhcPs)
35p_funBind name mgroup =
39p_funBind name mgroup =
36− p_matchGroup (Function (unL name)) mgroup
40+ p_matchGroup (Function name) mgroup
38data MatchGroupStyle
42data MatchGroupStyle
39− = Function RdrName
43+ = Function (Located RdrName)
42 | LambdaCase
47 | LambdaCase
@@ -47,14 +52,15 @@ p_matchGroup
48p_matchGroup style MG {..} =
53p_matchGroup style MG {..} =
49 locatedVia Nothing mg_alts $
54 locatedVia Nothing mg_alts $
50− newlineSep (located' (p_match style))
55+ newlineSep (located' (\Match {..} -> p_match style m_pats m_grhss))
51p_matchGroup _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
56p_matchGroup _ (XMatchGroup NoExt) = notImplemented "XMatchGroup"
54 :: MatchGroupStyle
59 :: MatchGroupStyle
55− -> Match GhcPs (LHsExpr GhcPs)
61+ -> GRHSs GhcPs (LHsExpr GhcPs)
57−p_match style Match {..} = do
63+p_match style m_pats m_grhss = do
58 case style of
64 case style of
59 Function name -> p_rdrName name
65 Function name -> p_rdrName name
60 _ -> return ()
66 _ -> return ()
@@ -76,10 +82,14 @@ p_match style Match {..} = do
76 switchLayout combinedSpans $ do
82 switchLayout combinedSpans $ do
77 case style of
83 case style of
78 Function _ -> breakpoint
84 Function _ -> breakpoint
85+ PatternBind -> return ()
79 Case -> return ()
86 Case -> return ()
80 Lambda -> txt "\\"
87 Lambda -> txt "\\"
81 LambdaCase -> return ()
88 LambdaCase -> return ()
89+ let wrapper = case style of
82− inci' (velt' (located' p_pat <$> m_pats))
92+ wrapper (velt' (located' p_pat <$> m_pats))
83 return inci'
93 return inci'
84 inci' $ do
94 inci' $ do
85 let GRHSs {..} = m_grhss
95 let GRHSs {..} = m_grhss
@@ -87,6 +97,7 @@ p_match style Match {..} = do
88 txt $ case style of
98 txt $ case style of
89 Function _ -> "="
99 Function _ -> "="
90 _ -> "->"
101 _ -> "->"
91 let combinedSpans = combineSrcSpans' $
102 let combinedSpans = combineSrcSpans' $
92 getGRHSSpan . unL <$> NE.fromList grhssGRHSs
103 getGRHSSpan . unL <$> NE.fromList grhssGRHSs
@@ -102,7 +113,6 @@ p_match style Match {..} = do
103 line (txt "where")
114 line (txt "where")
104 inci (located grhssLocalBinds p_hsLocalBinds)
115 inci (located grhssLocalBinds p_hsLocalBinds)
105−p_match _ (XMatch NoExt) = notImplemented "XMatchGroup"
107p_grhs :: GRHS GhcPs (LHsExpr GhcPs) -> R ()
117p_grhs :: GRHS GhcPs (LHsExpr GhcPs) -> R ()
108p_grhs (GRHS NoExt guards body) =
118p_grhs (GRHS NoExt guards body) =
@@ -148,13 +158,13 @@ p_hsLocalBinds = \case
149p_hsExpr :: HsExpr GhcPs -> R ()
159p_hsExpr :: HsExpr GhcPs -> R ()
150p_hsExpr = \case
160p_hsExpr = \case
151− HsVar NoExt name -> located name p_rdrName'
161+ HsVar NoExt name -> p_rdrName name
152 HsUnboundVar NoExt _ -> notImplemented "HsUnboundVar"
162 HsUnboundVar NoExt _ -> notImplemented "HsUnboundVar"
153 HsConLikeOut NoExt _ -> notImplemented "HsConLikeOut"
163 HsConLikeOut NoExt _ -> notImplemented "HsConLikeOut"
154 HsRecFld NoExt x ->
164 HsRecFld NoExt x ->
155 case x of
165 case x of
156− Unambiguous NoExt name -> located name p_rdrName'
166+ Unambiguous NoExt name -> p_rdrName name
157− Ambiguous NoExt name -> located name p_rdrName'
167+ Ambiguous NoExt name -> p_rdrName name
158 XAmbiguousFieldOcc NoExt -> notImplemented "XAmbiguousFieldOcc"
168 XAmbiguousFieldOcc NoExt -> notImplemented "XAmbiguousFieldOcc"
159 HsOverLabel NoExt _ _ -> notImplemented "HsOverLabel"
169 HsOverLabel NoExt _ _ -> notImplemented "HsOverLabel"
160 HsIPVar NoExt (HsIPName name) -> atom name
170 HsIPVar NoExt (HsIPName name) -> atom name
@@ -247,6 +257,45 @@ p_hsExpr = \case
247 HsWrap {} -> notImplemented "HsWrap"
257 HsWrap {} -> notImplemented "HsWrap"
248 XExpr {} -> notImplemented "XExpr"
258 XExpr {} -> notImplemented "XExpr"
260+p_patSynBind :: PatSynBind GhcPs GhcPs -> R ()
261+p_patSynBind PSB {..} = do
264+ Unidirectional -> do
267+ p_patSynDetails psb_args
270+ inci (located psb_def p_pat)
271+ ImplicitBidirectional -> do
274+ p_patSynDetails psb_args
277+ located psb_def p_pat
278+ ExplicitBidirectional mgroup -> do
281+ p_patSynDetails psb_args
284+ inci (located psb_def p_pat)
288+ inci (p_matchGroup (Function psb_id) mgroup)
289+p_patSynBind (XPatSynBind NoExt) = notImplemented "XPatSynBind"
291+p_patSynDetails :: HsPatSynDetails (Located RdrName) -> R ()
292+p_patSynDetails = \case
294+ velt' (p_rdrName <$> xs)
296+ velt' (p_rdrName . recordPatSynPatVar <$> xs)
297+ InfixCon _ _ -> notImplemented "InfixCon"
250----------------------------------------------------------------------------
299----------------------------------------------------------------------------
251-- Helpers
300-- Helpers