+ sig_vars = [sig_var | (TySigInfo sig_var _ _ _ _) <- ty_sigs]
+
+ (tyvars_to_gen, lie) = foldBag (\(tv1,lie2) (tv2,lie2) -> (tv1 `unionTyVarSets` tv2,
+ lie1 `plusLIE` lie2))
+ get
+ (emptyTyVarSet, emptyLIE)
+ binds_w_lies
+ get (bind, lie)
+ = case bindersOf bind of
+ [local_id] | local_id `in` sig_ids -> -- A simple binding with
+ -- a type signature
+ (emptyTyVarSet, emptyLIE)
+
+ local_ids -> -- Complex binding or no type sig
+ (foldr (unionTyVarSets . tcIdType) emptyTyVarSet local_ids,
+ lie)
+-}
+\end{code}
+
+
+
+\begin{code}
+tc_bind :: RenamedBind -> TcM s (TcBind s, LIE s)
+
+tc_bind (NonRecBind mono_binds)
+ = tcMonoBinds mono_binds `thenTc` \ (mono_binds2, lie) ->
+ returnTc (NonRecBind mono_binds2, lie)
+
+tc_bind (RecBind mono_binds)
+ = tcMonoBinds mono_binds `thenTc` \ (mono_binds2, lie) ->
+ returnTc (RecBind mono_binds2, lie)
+\end{code}
+
+\begin{code}
+tcMonoBinds :: RenamedMonoBinds -> TcM s (TcMonoBinds s, LIE s)
+
+tcMonoBinds EmptyMonoBinds = returnTc (EmptyMonoBinds, emptyLIE)
+
+tcMonoBinds (AndMonoBinds mb1 mb2)
+ = tcMonoBinds mb1 `thenTc` \ (mb1a, lie1) ->
+ tcMonoBinds mb2 `thenTc` \ (mb2a, lie2) ->
+ returnTc (AndMonoBinds mb1a mb2a, lie1 `plusLIE` lie2)
+
+tcMonoBinds bind@(PatMonoBind pat grhss_and_binds locn)
+ = tcAddSrcLoc locn $
+
+ -- LEFT HAND SIDE
+ tcPat pat `thenTc` \ (pat2, lie_pat, pat_ty) ->
+
+ -- BINDINGS AND GRHSS
+ tcGRHSsAndBinds grhss_and_binds `thenTc` \ (grhss_and_binds2, lie, grhss_ty) ->
+
+ -- Unify the two sides
+ tcAddErrCtxt (patMonoBindsCtxt bind) $
+ unifyTauTy pat_ty grhss_ty `thenTc_`
+
+ -- RETURN
+ returnTc (PatMonoBind pat2 grhss_and_binds2 locn,
+ plusLIE lie_pat lie)
+
+tcMonoBinds (FunMonoBind name inf matches locn)
+ = tcAddSrcLoc locn $
+ tcLookupLocalValueOK "tcMonoBinds" name `thenNF_Tc` \ id ->
+ tcMatchesFun name (idType id) matches `thenTc` \ (matches', lie) ->
+ returnTc (FunMonoBind (TcId id) inf matches' locn, lie)
+\end{code}
+
+%************************************************************************
+%* *
+\subsection{Signatures}
+%* *
+%************************************************************************
+
+@tcSigs@ checks the signatures for validity, and returns a list of
+{\em freshly-instantiated} signatures. That is, the types are already
+split up, and have fresh type variables installed. All non-type-signature
+"RenamedSigs" are ignored.
+
+\begin{code}
+tcTySigs :: [RenamedSig] -> TcM s [TcSigInfo s]
+
+tcTySigs (Sig v ty _ src_loc : other_sigs)
+ = tcAddSrcLoc src_loc (
+ tcPolyType ty `thenTc` \ sigma_ty ->
+ tcInstSigType sigma_ty `thenNF_Tc` \ sigma_ty' ->
+ let
+ (tyvars', theta', tau') = splitSigmaTy sigma_ty'
+ in
+
+ tcLookupLocalValueOK "tcSig1" v `thenNF_Tc` \ val ->
+ unifyTauTy (idType val) tau' `thenTc_`
+
+ returnTc (TySigInfo val tyvars' theta' tau' src_loc)
+ ) `thenTc` \ sig_info1 ->
+
+ tcTySigs other_sigs `thenTc` \ sig_infos ->
+ returnTc (sig_info1 : sig_infos)
+
+tcTySigs (other : sigs) = tcTySigs sigs
+tcTySigs [] = returnTc []
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{SPECIALIZE pragmas}
+%* *
+%************************************************************************
+