+\begin{code}
+ifaceVersions Nothing{-no iface handle-} _ = return ()
+
+ifaceVersions (Just if_hdl) version_info
+ = hPutStr if_hdl "__versions__\nFoo(1)" -- a stub, obviously
+\end{code}
+
+\begin{code}
+ifaceInstanceModules Nothing{-no iface handle-} _ = return ()
+ifaceInstanceModules (Just _) [] = return ()
+
+ifaceInstanceModules (Just if_hdl) imods
+ = hPutStr if_hdl "\n__instance_modules__\n" >>
+ hPutStr if_hdl (ppShow 100 (ppCat (map ppPStr imods)))
+\end{code}
+
+Export list: grab the Names of things that are marked Exported, sort
+(so the interface file doesn't ``wobble'' from one compilation to the
+next...), and print. Note that the ``module'' now contains all the
+imported things that we are dealing with, thus including any entities
+that we are re-exporting from somewhere else.
+\begin{code}
+ifaceExportList Nothing{-no iface handle-} _ = return ()
+
+ifaceExportList (Just if_hdl)
+ (HsModule _ _ _ _ _ typedecls _ classdecls _ _ _ binds sigs _)
+ = let
+ name_flag_pairs :: Bag (Name, ExportFlag)
+ name_flag_pairs
+ = foldr from_ty
+ (foldr from_cls
+ (foldr from_sig
+ (from_binds binds emptyBag{-init accum-})
+ sigs)
+ classdecls)
+ typedecls
+
+ sorted_pairs = sortLt lexical_lt (bagToList name_flag_pairs)
+
+ in
+ hPutStr if_hdl "\n__exports__\n" >>
+ hPutStr if_hdl (ppShow 100 (ppAboves (map pp_pair sorted_pairs)))
+ where
+ from_ty (TyData _ n _ _ _ _ _) acc = maybe_add acc n
+ from_ty (TyNew _ n _ _ _ _ _) acc = maybe_add acc n
+ from_ty (TySynonym n _ _ _) acc = maybe_add acc n
+
+ from_cls (ClassDecl _ n _ _ _ _ _) acc = maybe_add acc n
+
+ from_sig (Sig n _ _ _) acc = maybe_add acc n
+
+ from_binds bs acc = maybe_add_list acc (collectTopLevelBinders bs)
+
+ --------------
+ maybe_add :: Bag (Name, ExportFlag) -> RnName -> Bag (Name, ExportFlag)
+
+ maybe_add acc rn
+ | exportFlagOn ef = acc `snocBag` (n, ef)
+ | otherwise = acc
+ where
+ n = getName rn
+ ef = nameExportFlag n
+
+ --------------
+ maybe_add_list acc [] = acc
+ maybe_add_list acc (n:ns) = maybe_add (maybe_add_list acc ns) n
+
+ --------------
+ lexical_lt (n1,_) (n2,_) = nameOrigName n1 < nameOrigName n2
+
+ --------------
+ pp_pair (n, ef)
+ = ppBeside (ppr PprInterface (nameOrigName n)) (pp_export ef)
+ where
+ pp_export ExportAll = ppPStr SLIT("(..)")
+ pp_export ExportAbs = ppNil
+\end{code}
+
+\begin{code}
+ifaceFixities Nothing{-no iface handle-} _ = return ()
+
+ifaceFixities (Just if_hdl) (HsModule _ _ _ _ fixities _ _ _ _ _ _ _ _ _)
+ = if null fixities then
+ return ()
+ else
+ hPutStr if_hdl "\n__fixities__\n" >>
+ hPutStr if_hdl (ppShow 100 (ppAboves (map ppSemid fixities)))
+\end{code}
+
+\begin{code}
+ifaceDecls Nothing{-no iface handle-} _ = return ()
+
+ifaceDecls (Just if_hdl) (vals, tycons, classes, _)
+ = ASSERT(not (null vals && null tycons && null classes))
+ let
+ exported_classes = filter isExported classes
+ exported_tycons = filter isExported tycons
+ exported_vals = filter isExported vals
+
+ sorted_classes = sortLt ltLexical exported_classes
+ sorted_tycons = sortLt ltLexical exported_tycons
+ sorted_vals = sortLt ltLexical exported_vals
+ in
+ hPutStr if_hdl "\n__declarations__\n" >>
+ hPutStr if_hdl (ppShow 100 (ppAboves [
+ ppAboves (map ppSemid sorted_classes),
+ ppAboves (map ppSemid sorted_tycons),
+ ppAboves (map ppSemid sorted_vals)]))
+\end{code}
+
+\begin{code}
+ifaceInstances Nothing{-no iface handle-} _ = return ()
+
+ifaceInstances (Just if_hdl) (_, _, _, insts)
+ = return ()
+{-
+ let
+ exported_classes = filter isExported classes
+ exported_tycons = filter isExported tycons
+ exported_vals = filter isExported vals
+
+ sorted_classes = sortLt ltLexical exported_classes
+ sorted_tycons = sortLt ltLexical exported_tycons
+ sorted_vals = sortLt ltLexical exported_vals
+ in
+ hPutStr if_hdl "\n__declarations__\n" >>
+ hPutStr if_hdl (ppShow 100 (ppAboves [
+ ppAboves (map ppSemid sorted_classes),
+ ppAboves (map ppSemid sorted_tycons),
+ ppAboves (map ppSemid sorted_vals)]))
+-}
+\end{code}
+
+=== ALL OLD BELOW HERE ==============
+