-data HsBinds tyvar uvar id pat -- binders and bindees
- = EmptyBinds
-
- | ThenBinds (HsBinds tyvar uvar id pat)
- (HsBinds tyvar uvar id pat)
-
- | SingleBind (Bind tyvar uvar id pat)
-
- | BindWith -- Bind with a type signature.
- -- These appear only on typechecker input
- -- (PolyType [in Sigs] can't appear on output)
- (Bind tyvar uvar id pat)
- [Sig id]
-
- | AbsBinds -- Binds abstraction; TRANSLATION
- [tyvar]
- [id] -- Dicts
- [(id, id)] -- (old, new) pairs
- [(id, HsExpr tyvar uvar id pat)] -- local dictionaries
- (Bind tyvar uvar id pat) -- "the business end"
+data HsBindGroup id
+ = HsBindGroup -- A mutually recursive group
+ (LHsBinds id)
+ [LSig id] -- Empty on typechecker output, Type Signatures
+ RecFlag
+
+ | HsIPBinds
+ [LIPBind id] -- Not allowed at top level
+
+instance OutputableBndr id => Outputable (HsBindGroup id) where
+ ppr (HsBindGroup binds sigs is_rec)
+ = vcat [ppr_isrec,
+ vcat (map ppr sigs),
+ vcat (map ppr (bagToList binds))
+ -- *not* pprLHsBinds because we don't want braces; 'let' and
+ -- 'where' include a list of HsBindGroups and we don't want
+ -- several groups of bindings each with braces around.
+ ]
+ where
+ ppr_isrec = getPprStyle $ \ sty ->
+ if userStyle sty then empty else
+ case is_rec of
+ Recursive -> ptext SLIT("{- rec -}")
+ NonRecursive -> ptext SLIT("{- nonrec -}")
+
+ ppr (HsIPBinds ipbinds)
+ = vcat (map ppr ipbinds)
+
+-- -----------------------------------------------------------------------------
+-- Implicit parameter bindings
+
+type LIPBind id = Located (IPBind id)
+
+-- | Implicit parameter bindings.
+data IPBind id
+ = IPBind
+ (IPName id)
+ (LHsExpr id)
+
+instance (OutputableBndr id) => Outputable (IPBind id) where
+ ppr (IPBind id rhs) = pprBndr LetBind id <+> equals <+> pprExpr (unLoc rhs)
+
+-- -----------------------------------------------------------------------------
+
+type LHsBinds id = Bag (LHsBind id)
+type LHsBind id = Located (HsBind id)
+
+pprLHsBinds :: OutputableBndr id => LHsBinds id -> SDoc
+pprLHsBinds binds = lbrace <+> vcat (map ppr (bagToList binds)) <+> rbrace
+
+data HsBind id
+ = FunBind (Located id)
+ -- Used for both functions f x = e
+ -- and variables f = \x -> e
+ -- Reason: the Match stuff lets us have an optional
+ -- result type sig f :: a->a = ...mentions a...
+ --
+ -- This also means that instance decls can only have
+ -- FunBinds, so if you change this, you'll need to
+ -- change e.g. rnMethodBinds
+ Bool -- True => infix declaration
+ [LMatch id]
+
+ | PatBind (LPat id) -- The pattern is never a simple variable;
+ -- That case is done by FunBind
+ (GRHSs id)
+
+ | VarBind id (Located (HsExpr id)) -- Dictionary binding and suchlike;
+ -- located only for consistency
+
+ | AbsBinds -- Binds abstraction; TRANSLATION
+ [TyVar] -- Type variables
+ [id] -- Dicts
+ [([TyVar], id, id)] -- (type variables, polymorphic, momonmorphic) triples
+ NameSet -- Set of *polymorphic* variables that have an INLINE pragma
+ (LHsBinds id) -- The "business end"