+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 { -- FunBind is used for both functions f x = e
+ -- and variables f = \x -> e
+-- Reason 1: the Match stuff lets us have an optional
+-- result type sig f :: a->a = ...mentions a...
+--
+-- Reason 2: Special case for type inference: see TcBinds.tcMonoBinds
+--
+-- Reason 3: instance decls can only have FunBinds, which is convenient
+-- If you change this, you'll need tochange e.g. rnMethodBinds
+
+ fun_id :: Located id,
+
+ fun_infix :: Bool, -- True => infix declaration
+
+ fun_matches :: MatchGroup id, -- The payload
+
+ fun_co_fn :: ExprCoFn, -- Coercion from the type of the MatchGroup to the type of
+ -- the Id. Example:
+ -- f :: Int -> forall a. a -> a
+ -- f x y = y
+ -- Then the MatchGroup will have type (Int -> a' -> a')
+ -- (with a free type variable a'). The coercion will take
+ -- a CoreExpr of this type and convert it to a CoreExpr of
+ -- type Int -> forall a'. a' -> a'
+ -- Notice that the coercion captures the free a'. That's
+ -- why coercions are (CoreExpr -> CoreExpr), rather than
+ -- just CoreExpr (with a functional type)
+
+ bind_fvs :: 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 { -- The pattern is never a simple variable;
+ -- That case is done by FunBind
+ pat_lhs :: LPat id,
+ pat_rhs :: GRHSs id,
+ pat_rhs_ty :: PostTcType, -- Type of the GRHSs
+ bind_fvs :: NameSet -- Same as for FunBind
+ }
+
+ | VarBind { -- Dictionary binding and suchlike
+ var_id :: id, -- All VarBinds are introduced by the type checker
+ var_rhs :: LHsExpr id -- Located only for consistency
+ }
+
+ | AbsBinds { -- Binds abstraction; TRANSLATION
+ abs_tvs :: [TyVar],
+ abs_dicts :: [DictId],
+ abs_exports :: [([TyVar], id, id, [Prag])], -- (tvs, poly_id, mono_id, prags)
+ abs_binds :: 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.)