+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 expressiona and patterns
+ = HsRecFields { rec_flds :: [HsRecField id arg],
+ rec_dotdot :: Maybe Int }
+ -- Nothing => the normal case
+ -- Just n => the group uses ".." notation,
+ -- and the first n elts of rec_flds
+ -- were the user-written ones
+ -- (In the latter case, the remaining elts of
+ -- rec_flds are the non-user-written ones)
+
+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 immediately expanded to x=x
+-- but with a punning flag so we can detect it later
+-- (e.g. when pretty printing)
+
+hsRecFields :: HsRecFields id arg -> [id]
+hsRecFields rbinds = map (unLoc . hsRecFieldId) (rec_flds rbinds)
+\end{code}