+dsImpSpecs :: [LTcSpecPrag] -> DsM (OrdList (Id,CoreExpr), [CoreRule])
+dsImpSpecs imp_specs
+ = do { spec_prs <- mapMaybeM (dsSpec Nothing) imp_specs
+ ; let (spec_binds, spec_rules) = unzip spec_prs
+ ; return (concatOL spec_binds, spec_rules) }
+
+combineEvBinds :: [DsEvBind] -> [(Id,CoreExpr)] -> [CoreBind]
+-- Top-level bindings can include coercion bindings, but not via superclasses
+-- See Note [Top-level evidence]
+combineEvBinds [] val_prs
+ = [Rec val_prs]
+combineEvBinds (LetEvBind (NonRec b r) : bs) val_prs
+ | isId b = combineEvBinds bs ((b,r):val_prs)
+ | otherwise = NonRec b r : combineEvBinds bs val_prs
+combineEvBinds (LetEvBind (Rec prs) : bs) val_prs
+ = combineEvBinds bs (prs ++ val_prs)
+combineEvBinds (CaseEvBind x _ _ : _) _
+ = pprPanic "topEvBindPairs" (ppr x)
+\end{code}
+
+Note [Top-level evidence]
+~~~~~~~~~~~~~~~~~~~~~~~~~
+Top-level evidence bindings may be mutually recursive with the top-level value
+bindings, so we must put those in a Rec. But we can't put them *all* in a Rec
+because the occurrence analyser doesn't teke account of type/coercion variables
+when computing dependencies.
+
+So we pull out the type/coercion variables (which are in dependency order),
+and Rec the rest.
+
+
+\begin{code}
+mkAutoScc :: DynFlags -> Module -> NameSet -> AutoScc
+mkAutoScc dflags mod exports
+ | not opt_SccProfilingOn -- No profiling
+ = NoSccs
+ -- Add auto-scc on all top-level things
+ | dopt Opt_AutoSccsOnAllToplevs dflags
+ = AddSccs mod (\id -> not $ isDerivedOccName $ getOccName id)
+ -- See #1641. This is pretty yucky, but I can't see a better way
+ -- to identify compiler-generated Ids, and at least this should
+ -- catch them all.
+ -- Only on exported things
+ | dopt Opt_AutoSccsOnExportedToplevs dflags
+ = AddSccs mod (\id -> idName id `elemNameSet` exports)
+ | otherwise
+ = NoSccs