- getSrcLocRn `thenRn` \ src_loc ->
- mapRn (addWarnRn . dupNameExportWarn src_loc) dup_tc_names `thenRn_`
- mapRn (addWarnRn . dupNameExportWarn src_loc) dup_val_names `thenRn_`
- mapRn (addWarnRn . dupModExportWarn src_loc) dup_mods `thenRn_`
- mapRn (addWarnRn . emptyModExportWarn src_loc) empty_mods `thenRn_`
- mapRn (addErrRn . dupLocalsExportErr src_loc) dup_tc_locals `thenRn_`
- mapRn (addErrRn . dupLocalsExportErr src_loc) dup_val_locals `thenRn_`
- returnRn exp_fn
-
-
-rnIE mods (IEVar name)
- = lookupValue name `thenRn` \ rn ->
- checkIEVar rn `thenRn` \ exps ->
- returnRn (Nothing, exps)
- where
- checkIEVar (RnName n) = returnRn (emptyBag, unitBag (n,ExportAll))
- checkIEVar rn@(RnClassOp _ _) = getSrcLocRn `thenRn` \ src_loc ->
- failButContinueRn (emptyBag, emptyBag) (classOpExportErr rn src_loc)
- checkIEVar rn = returnRn (emptyBag, emptyBag)
-
-rnIE mods (IEThingAbs name)
- = lookupTyConOrClass name `thenRn` \ rn ->
- checkIEAbs rn `thenRn` \ exps ->
- returnRn (Nothing, exps)
- where
- checkIEAbs (RnSyn n) = returnRn (unitBag (n,ExportAbs), emptyBag)
- checkIEAbs (RnData n _ _) = returnRn (unitBag (n,ExportAbs), emptyBag)
- checkIEAbs (RnClass n _) = returnRn (unitBag (n,ExportAbs), emptyBag)
- checkIEAbs rn = returnRn (emptyBag, emptyBag)
-
-rnIE mods (IEThingAll name)
- = lookupTyConOrClass name `thenRn` \ rn ->
- checkIEAll rn `thenRn` \ exps ->
- checkImportAll rn `thenRn_`
- returnRn (Nothing, exps)
- where
- checkIEAll (RnData n cons fields) = returnRn (unitBag (exp_all n), listToBag (map exp_all cons)
- `unionBags`
- listToBag (map exp_all fields))
- checkIEAll (RnClass n ops) = returnRn (unitBag (exp_all n), listToBag (map exp_all ops))
- checkIEAll rn@(RnSyn n) = getSrcLocRn `thenRn` \ src_loc ->
- warnAndContinueRn (unitBag (n, ExportAbs), emptyBag)
- (synAllExportErr False{-warning-} rn src_loc)
- checkIEAll rn = returnRn (emptyBag, emptyBag)
-
- exp_all n = (n, ExportAll)
-
-rnIE mods (IEThingWith name names)
- = lookupTyConOrClass name `thenRn` \ rn ->
- mapRn lookupValue names `thenRn` \ rns ->
- checkIEWith rn rns `thenRn` \ exps ->
- checkImportAll rn `thenRn_`
- returnRn (Nothing, exps)
- where
- checkIEWith rn@(RnData n cons fields) rns
- | same_names (cons++fields) rns
- = returnRn (unitBag (exp_all n), listToBag (map exp_all cons)
- `unionBags`
- listToBag (map exp_all fields))
- | otherwise
- = rnWithErr "constructors (and fields)" rn (cons++fields) rns
- checkIEWith rn@(RnClass n ops) rns
- | same_names ops rns
- = returnRn (unitBag (exp_all n), listToBag (map exp_all ops))
- | otherwise
- = rnWithErr "class ops" rn ops rns
- checkIEWith rn@(RnSyn _) rns
- = getSrcLocRn `thenRn` \ src_loc ->
- failButContinueRn (emptyBag, emptyBag) (synAllExportErr True{-error-} rn src_loc)
- checkIEWith rn rns
- = returnRn (emptyBag, emptyBag)
-
- exp_all n = (n, ExportAll)
-
- same_names has rns
- = all (not.isRnUnbound) rns &&
- sortLt (<) (map uniqueOf has) == sortLt (<) (map uniqueOf rns)
-
- rnWithErr str rn has rns
- = getSrcLocRn `thenRn` \ src_loc ->
- failButContinueRn (emptyBag, emptyBag) (withExportErr str rn has rns src_loc)
-
-rnIE mods (IEModuleContents mod)
- | isIn "rnIE:IEModule" mod mods
- = returnRn (Just mod, (emptyBag, emptyBag))
- | otherwise
- = getSrcLocRn `thenRn` \ src_loc ->
- failButContinueRn (Nothing, (emptyBag, emptyBag)) (badModExportErr mod src_loc)