+data HsLocalBinds id -- Bindings in a 'let' expression
+ -- or a 'where' clause
+ = HsValBinds (HsValBinds id)
+ | HsIPBinds (HsIPBinds id)
+ | EmptyLocalBinds
+
+data HsValBinds id -- Value bindings (not implicit parameters)
+ = ValBindsIn -- Before typechecking
+ (LHsBinds id) [LSig id] -- Not dependency analysed
+ -- Recursive by default
+
+ | ValBindsOut -- After renaming
+ [(RecFlag, LHsBinds id)] -- Dependency analysed
+ [LSig Name]
+
+type LHsBinds id = Bag (LHsBind id)
+type DictBinds id = LHsBinds id -- Used for dictionary or method bindings
+type LHsBind id = Located (HsBind id)
+
+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
+ (MatchGroup id)
+ NameSet -- After the renamer, this contains a superset of the
+ -- Names of the other binders in this binding group that
+ -- are free in the RHS of the defn
+ -- Before renaming, and after typechecking,
+ -- the field is unused; it's just an error thunk
+
+ | PatBind (LPat id) -- The pattern is never a simple variable;
+ -- That case is done by FunBind
+ (GRHSs id)
+ PostTcType -- Type of the GRHSs
+ NameSet -- Same as for FunBind
+
+ | VarBind id (Located (HsExpr id)) -- Dictionary binding and suchlike
+ -- All VarBinds are introduced by the type checker
+ -- Located only for consistency
+
+ | AbsBinds -- Binds abstraction; TRANSLATION
+ [TyVar] -- Type variables
+ [DictId] -- Dicts
+ [([TyVar], id, id, [Prag])] -- (tvs, poly_id, mono_id, prags)
+ (LHsBinds id) -- The dictionary bindings and typechecked user bindings
+ -- mixed up together; you can tell the dict bindings because
+ -- they are all VarBinds
+
+ -- Consider (AbsBinds tvs ds [(ftvs, poly_f, mono_f) binds]
+ --
+ -- Creates bindings for (polymorphic, overloaded) poly_f
+ -- in terms of monomorphic, non-overloaded mono_f
+ --
+ -- Invariants:
+ -- 1. 'binds' binds mono_f
+ -- 2. ftvs is a subset of tvs
+ -- 3. ftvs includes all tyvars free in ds
+ --
+ -- See section 9 of static semantics paper for more details.
+ -- (You can get a PhD for explaining the True Meaning
+ -- of this last construct.)