@@ -484,21 +484,8 @@ p_hsExpr = \case
484484 sep comma (located' p_hsTupArg) args
485485 else switchLayout (getLoc <$> args) . parens' . sitcc $
486486 sep (comma >> breakpoint) (sitcc . located' p_hsTupArg) args
487− ExplicitSum NoExt tag arity e -> do
488− let before = tag - 1
489− after = arity - before - 1
490− args = replicate before Nothing <> [Just e] <> replicate after Nothing
491− f (x,i) = do
492− let isFirst = i == 0
493− isLast = i == arity - 1
494− case x of
495− Nothing ->
496− unless (isFirst || isLast) space
497− Just l -> do
498− unless isFirst space
499− located l p_hsExpr
500− unless isLast space
501− parensHash $ sep (txt "|") f (zip args [0..])
487+ ExplicitSum NoExt tag arity e ->
488+ p_unboxedSum tag arity (located e p_hsExpr)
502489 HsCase NoExt e mgroup -> do
503490 txt "case "
504491 located e p_hsExpr
@@ -710,9 +697,8 @@ p_pat = \case
710697 Boxed -> parens
711698 Unboxed -> parensHash
712699 f . sitcc $ sep (comma >> breakpoint) (sitcc . located' p_pat) pats
713− SumPat NoExt pat _ _ -> do
714− -- XXX I'm not sure about this one.
715− located pat p_pat
700+ SumPat NoExt pat tag arity ->
701+ p_unboxedSum tag arity (located pat p_pat)
716702 ConPatIn pat details ->
717703 case details of
718704 PrefixCon xs -> sitcc $ do
@@ -765,6 +751,23 @@ p_pat_hsRecField HsRecField {..} = do
765751 breakpoint
766752 inci (located hsRecFieldArg p_pat)
767753
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
759+ f (x,i) = do
760+ let isFirst = i == 0
761+ isLast = i == arity - 1
762+ case x :: Maybe (R ()) of
763+ Nothing ->
764+ unless (isFirst || isLast) space
765+ Just m' -> do
766+ unless isFirst space
767+ m'
768+ unless isLast space
769+ parensHash $ sep (txt "|") f (zip args [0..])
770+
768771p_hsSplice :: HsSplice GhcPs -> R ()
769772p_hsSplice = \case
770773 HsTypedSplice NoExt deco _ expr -> p_hsSpliceTH True expr deco