-data HsConDetails id arg
- = PrefixCon [arg] -- C p1 p2 p3
- | RecCon [(Located id, arg)] -- C { x = p1, y = p2 }
- | InfixCon arg arg -- p1 `C` p2
-
-hsConArgs :: HsConDetails id arg -> [arg]
-hsConArgs (PrefixCon ps) = ps
-hsConArgs (RecCon fs) = map snd fs
-hsConArgs (InfixCon p1 p2) = [p1,p2]
+data HsConDetails arg rec
+ = PrefixCon [arg] -- C p1 p2 p3
+ | RecCon rec -- C { x = p1, y = p2 }
+ | InfixCon arg arg -- p1 `C` p2
+
+type HsConPatDetails id = HsConDetails (LPat id) (HsRecFields id (LPat id))
+
+hsConPatArgs :: HsConPatDetails id -> [LPat id]
+hsConPatArgs (PrefixCon ps) = ps
+hsConPatArgs (RecCon fs) = map hsRecFieldArg (rec_flds fs)
+hsConPatArgs (InfixCon p1 p2) = [p1,p2]
+\end{code}
+
+However HsRecFields is used only for patterns and expressions
+(not data type declarations)
+
+\begin{code}
+data HsRecFields id arg -- A bunch of record fields
+ -- { x = 3, y = True }
+ -- Used for both expressions and patterns
+ = HsRecFields { rec_flds :: [HsRecField id arg],
+ rec_dotdot :: Maybe Int } -- Note [DotDot fields]
+
+-- Note [DotDot fields]
+-- ~~~~~~~~~~~~~~~~~~~~
+-- The rec_dotdot field means this:
+-- Nothing => the normal case
+-- Just n => the group uses ".." notation,
+--
+-- In the latter case:
+--
+-- *before* renamer: rec_flds are exactly the n user-written fields
+--
+-- *after* renamer: rec_flds includes *all* fields, with
+-- the first 'n' being the user-written ones
+-- and the remainder being 'filled in' implicitly
+
+data HsRecField id arg = HsRecField {
+ hsRecFieldId :: Located id,
+ hsRecFieldArg :: arg,
+ hsRecPun :: Bool -- Note [Punning]
+ }
+
+-- Note [Punning]
+-- ~~~~~~~~~~~~~~
+-- If you write T { x, y = v+1 }, the HsRecFields will be
+-- HsRecField x x True ...
+-- HsRecField y (v+1) False ...
+-- That is, for "punned" field x is expanded (in the renamer)
+-- to x=x; but with a punning flag so we can detect it later
+-- (e.g. when pretty printing)
+--
+-- If the original field was qualified, we un-qualify it, thus
+-- T { A.x } means T { A.x = x }
+
+hsRecFields :: HsRecFields id arg -> [id]
+hsRecFields rbinds = map (unLoc . hsRecFieldId) (rec_flds rbinds)
+\end{code}
+
+\begin{code}
+data HsQuasiQuote id = HsQuasiQuote
+ id
+ id
+ SrcSpan
+ FastString
+
+instance OutputableBndr id => Outputable (HsQuasiQuote id) where
+ ppr = ppr_qq
+
+ppr_qq :: OutputableBndr id => HsQuasiQuote id -> SDoc
+ppr_qq (HsQuasiQuote name quoter _ quote) =
+ char '$' <> brackets (ppr name) <>
+ ptext (sLit "[:") <> ppr quoter <> ptext (sLit "|") <>
+ ppr quote <> ptext (sLit "|]")