- -> RnM (HsValBindsLR Name RdrName)
-rnValBindsLHS fix_env binds =
- let (boundNames,doc) = bindersAndDoc binds
- in rnValBindsLHSFromDoc_Local boundNames doc fix_env binds
-
--- a helper used for local binds that does the duplicates check,
--- just so we don't forget to do it somewhere
-rnValBindsLHSFromDoc_Local :: [Located RdrName] -- RdrNames of the LHS (so we don't have to gather them twice)
- -> SDoc -- doc string for dup names and shadowing
- -> MiniFixityEnv
- -> HsValBinds RdrName
- -> RnM (HsValBindsLR Name RdrName)
-
-rnValBindsLHSFromDoc_Local boundNames doc fix_env binds = do
- -- Do error checking: we need to check for dups here because we
- -- don't don't bind all of the variables from the ValBinds at once
- -- with bindLocatedLocals any more.
- checkDupAndShadowedRdrNames doc boundNames
-
- -- (Note that we don't want to do this at the top level, since
- -- sorting out duplicates and shadowing there happens elsewhere.
- -- The behavior is even different. For example,
- -- import A(f)
- -- f = ...
- -- should not produce a shadowing warning (but it will produce
- -- an ambiguity warning if you use f), but
- -- import A(f)
- -- g = let f = ... in f
- -- should.
- rnValBindsLHSFromDoc (localRecNameMaker fix_env) boundNames doc binds
-
-bindersAndDoc :: HsValBinds RdrName -> ([Located RdrName], SDoc)
-bindersAndDoc binds =
- let
- -- the unrenamed bndrs for error checking and reporting
- orig = collectHsValBinders binds
- doc = text "In the binding group for:" <+> pprWithCommas ppr (map unLoc orig)
- in
- (orig, doc)
+ -> RnM ([Name], HsValBindsLR Name RdrName)
+rnValBindsLHS fix_env binds
+ = do { -- Do error checking: we need to check for dups here because we
+ -- don't don't bind all of the variables from the ValBinds at once
+ -- with bindLocatedLocals any more.
+ --
+ -- Note that we don't want to do this at the top level, since
+ -- sorting out duplicates and shadowing there happens elsewhere.
+ -- The behavior is even different. For example,
+ -- import A(f)
+ -- f = ...
+ -- should not produce a shadowing warning (but it will produce
+ -- an ambiguity warning if you use f), but
+ -- import A(f)
+ -- g = let f = ... in f
+ -- should.
+ ; binds' <- rnValBindsLHSFromDoc (localRecNameMaker fix_env) binds
+ ; let bound_names = collectHsValBinders binds'
+ ; envs <- getRdrEnvs
+ ; checkDupAndShadowedNames envs bound_names
+ ; return (bound_names, binds') }