@@ -24,18 +24,24 @@ p_dataDecl
2424 :: FamilyStyle -- ^ Whether to format as data family
2525 -> Located RdrName -- ^ Type constructor
2626 -> [LHsType GhcPs] -- ^ Type patterns
27+ -> LexicalFixity -- ^ Lexical fixity
2728 -> HsDataDefn GhcPs -- ^ Data definition
2829 -> R ()
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))
3032 txt $ case dd_ND of
31− NewType -> "newtype "
32− DataType -> "data "
33+ NewType -> "newtype"
34+ DataType -> "data"
3335 txt $ case style of
3436 Associated -> mempty
35− Free -> "instance "
36− p_rdrName name
37− unless (null tpats) space
38− spaceSep (located' p_hsType) tpats
37+ Free -> " instance"
38+ switchLayout combinedSpans $ do
39+ breakpoint
40+ inci $ p_infixDefHelper
41+ (isInfix fixity)
42+ inci
43+ (p_rdrName name)
44+ (located' p_hsType <$> tpats)
3945 case dd_kindSig of
4046 Nothing -> return ()
4147 Just k -> do
@@ -58,7 +64,7 @@ p_dataDecl style name tpats HsDataDefn {..} = do
5864 newline
5965 inci . located dd_derivs $ \xs ->
6066 forM_ xs (line . located' p_hsDerivingClause)
61−p_dataDecl _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
67+p_dataDecl _ _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
6268
6369p_conDecl :: ConDecl GhcPs -> R ()
6470p_conDecl = \case
@@ -165,3 +171,11 @@ p_hsDerivingClause HsDerivingClause {..} = do
165171 ViaStrategy (XHsImplicitBndrs NoExt) ->
166172 notImplemented "XHsImplicitBndrs"
167173p_hsDerivingClause (XHsDerivingClause NoExt) = notImplemented "XHsDerivingClause"
174+
175+----------------------------------------------------------------------------
176+-- Helpers
177+
178+isInfix :: LexicalFixity -> Bool
179+isInfix = \case
180+ Infix -> True
181+ Prefix -> False