-rnTopMonoBinds mbinds sigs
- = mappM lookupBndrRn binder_rdr_names `thenM` \ binder_names ->
- bindPatSigTyVars (collectSigTysFromMonoBinds mbinds) $
- let
- bndr_name_set = mkNameSet binder_names
- in
- renameSigsFVs (okBindSig bndr_name_set) sigs `thenM` \ (siglist, sig_fvs) ->
-
- -- Warn about missing signatures, but not in interface mode
- -- (This is important when renaming bindings from 'deriving' clauses.)
- getModeRn `thenM` \ mode ->
- doptM Opt_WarnMissingSigs `thenM` \ warn_missing_sigs ->
- (if warn_missing_sigs && not (isInterfaceMode mode) then
- let
- type_sig_vars = [n | Sig n _ _ <- siglist]
- un_sigd_binders = nameSetToList (delListFromNameSet bndr_name_set type_sig_vars)
- in
- mappM_ missingSigWarn un_sigd_binders
- else
- returnM ()
- ) `thenM_`
-
- rn_mono_binds siglist mbinds `thenM` \ (final_binds, bind_fvs) ->
- returnM (final_binds, bind_fvs `plusFV` sig_fvs)
- where
- binder_rdr_names = collectMonoBinders mbinds
+rnTopBinds :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
+
+-- The binders of the binding are in scope already;
+-- the top level scope resolution does that
+
+rnTopBinds binds
+ = do { is_boot <- tcIsHsBoot
+ ; if is_boot then rnTopBindsBoot binds
+ else rnTopBindsSrc binds }
+
+rnTopBindsBoot :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
+-- A hs-boot file has no bindings.
+-- Return a single HsBindGroup with empty binds and renamed signatures
+rnTopBindsBoot (ValBindsIn mbinds sigs)
+ = do { checkErr (isEmptyLHsBinds mbinds) (bindsInHsBootFile mbinds)
+ ; sigs' <- renameSigs okHsBootSig sigs
+ ; return (ValBindsOut [] sigs', usesOnly (hsSigsFVs sigs')) }
+
+rnTopBindsSrc :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
+rnTopBindsSrc binds@(ValBindsIn mbinds _)
+ = do { (binds', dus) <- rnValBinds noTrim binds
+
+ -- Warn about missing signatures,
+ ; let { ValBindsOut _ sigs' = binds'
+ ; ty_sig_vars = mkNameSet [ unLoc n | L _ (TypeSig n _) <- sigs']
+ ; un_sigd_bndrs = duDefs dus `minusNameSet` ty_sig_vars }
+
+ ; warn_missing_sigs <- doptM Opt_WarnMissingSigs
+ ; ifM (warn_missing_sigs)
+ (mappM_ missingSigWarn (nameSetToList un_sigd_bndrs))
+
+ ; return (binds', dus)
+ }
+\end{code}
+
+
+
+%*********************************************************
+%* *
+ HsLocalBinds
+%* *
+%*********************************************************
+
+\begin{code}
+rnLocalBindsAndThen
+ :: HsLocalBinds RdrName
+ -> (HsLocalBinds Name -> RnM (result, FreeVars))
+ -> RnM (result, FreeVars)
+-- This version (a) assumes that the binding vars are not already in scope
+-- (b) removes the binders from the free vars of the thing inside
+-- The parser doesn't produce ThenBinds
+rnLocalBindsAndThen EmptyLocalBinds thing_inside
+ = thing_inside EmptyLocalBinds
+
+rnLocalBindsAndThen (HsValBinds val_binds) thing_inside
+ = rnValBindsAndThen val_binds $ \ val_binds' ->
+ thing_inside (HsValBinds val_binds')
+
+rnLocalBindsAndThen (HsIPBinds binds) thing_inside
+ = rnIPBinds binds `thenM` \ (binds',fv_binds) ->
+ thing_inside (HsIPBinds binds') `thenM` \ (thing, fvs_thing) ->
+ returnM (thing, fvs_thing `plusFV` fv_binds)
+
+-------------
+rnIPBinds (IPBinds ip_binds _no_dict_binds)
+ = do { (ip_binds', fvs_s) <- mapAndUnzipM (wrapLocFstM rnIPBind) ip_binds
+ ; return (IPBinds ip_binds' emptyLHsBinds, plusFVs fvs_s) }
+
+rnIPBind (IPBind n expr)
+ = newIPNameRn n `thenM` \ name ->
+ rnLExpr expr `thenM` \ (expr',fvExpr) ->
+ return (IPBind name expr', fvExpr)