@@ -484,21 +484,8 @@ p_hsExpr = \case
484 sep comma (located' p_hsTupArg) args
484 sep comma (located' p_hsTupArg) args
485 else switchLayout (getLoc <$> args) . parens' . sitcc $
485 else switchLayout (getLoc <$> args) . parens' . sitcc $
486 sep (comma >> breakpoint) (sitcc . located' p_hsTupArg) args
486 sep (comma >> breakpoint) (sitcc . located' p_hsTupArg) args
487− ExplicitSum NoExt tag arity e -> do
487+ ExplicitSum NoExt tag arity e ->
488− let before = tag - 1
489− after = arity - before - 1
490− args = replicate before Nothing <> [Just e] <> replicate after Nothing
492− let isFirst = i == 0
493− isLast = i == arity - 1
496− unless (isFirst || isLast) space
498− unless isFirst space
499− located l p_hsExpr
488+ p_unboxedSum tag arity (located e p_hsExpr)
501− parensHash $ sep (txt "|") f (zip args [0..])
502 HsCase NoExt e mgroup -> do
489 HsCase NoExt e mgroup -> do
503 txt "case "
490 txt "case "
504 located e p_hsExpr
491 located e p_hsExpr
@@ -710,9 +697,8 @@ p_pat = \case
710 Boxed -> parens
697 Boxed -> parens
711 Unboxed -> parensHash
698 Unboxed -> parensHash
712 f . sitcc $ sep (comma >> breakpoint) (sitcc . located' p_pat) pats
699 f . sitcc $ sep (comma >> breakpoint) (sitcc . located' p_pat) pats
713− SumPat NoExt pat _ _ -> do
700+ SumPat NoExt pat tag arity ->
714− -- XXX I'm not sure about this one.
715− located pat p_pat
701+ p_unboxedSum tag arity (located pat p_pat)
716 ConPatIn pat details ->
702 ConPatIn pat details ->
717 case details of
703 case details of
718 PrefixCon xs -> sitcc $ do
704 PrefixCon xs -> sitcc $ do
@@ -765,6 +751,23 @@ p_pat_hsRecField HsRecField {..} = do
765 breakpoint
751 breakpoint
766 inci (located hsRecFieldArg p_pat)
752 inci (located hsRecFieldArg p_pat)
754+p_unboxedSum :: ConTag -> Arity -> R () -> R ()
755+p_unboxedSum tag arity m = do
756+ let before = tag - 1
757+ after = arity - before - 1
758+ args = replicate before Nothing <> [Just m] <> replicate after Nothing
760+ let isFirst = i == 0
761+ isLast = i == arity - 1
762+ case x :: Maybe (R ()) of
764+ unless (isFirst || isLast) space
766+ unless isFirst space
769+ parensHash $ sep (txt "|") f (zip args [0..])
768p_hsSplice :: HsSplice GhcPs -> R ()
771p_hsSplice :: HsSplice GhcPs -> R ()
769p_hsSplice = \case
772p_hsSplice = \case
770 HsTypedSplice NoExt deco _ expr -> p_hsSpliceTH True expr deco
773 HsTypedSplice NoExt deco _ expr -> p_hsSpliceTH True expr deco