@@ -24,18 +24,24 @@ p_dataDecl
24 :: FamilyStyle -- ^ Whether to format as data family
24 :: FamilyStyle -- ^ Whether to format as data family
25 -> Located RdrName -- ^ Type constructor
25 -> Located RdrName -- ^ Type constructor
26 -> [LHsType GhcPs] -- ^ Type patterns
26 -> [LHsType GhcPs] -- ^ Type patterns
27+ -> LexicalFixity -- ^ Lexical fixity
27 -> HsDataDefn GhcPs -- ^ Data definition
28 -> HsDataDefn GhcPs -- ^ Data definition
29−p_dataDecl style name tpats HsDataDefn {..} = do
30+p_dataDecl style name tpats fixity HsDataDefn {..} = do
31+ let combinedSpans = combineSrcSpans' (getLoc name :| (getLoc <$> tpats))
30 txt $ case dd_ND of
32 txt $ case dd_ND of
31− NewType -> "newtype "
33+ NewType -> "newtype"
32− DataType -> "data "
34+ DataType -> "data"
33 txt $ case style of
35 txt $ case style of
34 Associated -> mempty
36 Associated -> mempty
35− Free -> "instance "
37+ Free -> " instance"
38+ switchLayout combinedSpans $ do
40+ inci $ p_infixDefHelper
36− p_rdrName name
43+ (p_rdrName name)
37− unless (null tpats) space
38− spaceSep (located' p_hsType) tpats
44+ (located' p_hsType <$> tpats)
39 case dd_kindSig of
45 case dd_kindSig of
40 Nothing -> return ()
46 Nothing -> return ()
41 Just k -> do
47 Just k -> do
@@ -58,7 +64,7 @@ p_dataDecl style name tpats HsDataDefn {..} = do
59 inci . located dd_derivs $ \xs ->
65 inci . located dd_derivs $ \xs ->
60 forM_ xs (line . located' p_hsDerivingClause)
66 forM_ xs (line . located' p_hsDerivingClause)
61−p_dataDecl _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
67+p_dataDecl _ _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
63p_conDecl :: ConDecl GhcPs -> R ()
69p_conDecl :: ConDecl GhcPs -> R ()
64p_conDecl = \case
70p_conDecl = \case
@@ -165,3 +171,11 @@ p_hsDerivingClause HsDerivingClause {..} = do
165 ViaStrategy (XHsImplicitBndrs NoExt) ->
171 ViaStrategy (XHsImplicitBndrs NoExt) ->
166 notImplemented "XHsImplicitBndrs"
172 notImplemented "XHsImplicitBndrs"
167p_hsDerivingClause (XHsDerivingClause NoExt) = notImplemented "XHsDerivingClause"
173p_hsDerivingClause (XHsDerivingClause NoExt) = notImplemented "XHsDerivingClause"
175+----------------------------------------------------------------------------
178+isInfix :: LexicalFixity -> Bool