+\end{code}
+
+
+%************************************************************************
+%* *
+ Printing interfaces
+%* *
+%************************************************************************
+
+\begin{code}
+-- | Read binary interface, and print it out
+showIface :: HscEnv -> FilePath -> IO ()
+showIface hsc_env filename = do
+ -- skip the hi way check; we don't want to worry about profiled vs.
+ -- non-profiled interfaces, for example.
+ iface <- initTcRnIf 's' hsc_env () () $
+ readBinIface IgnoreHiWay TraceBinIFaceReading filename
+ printDump (pprModIface iface)
+\end{code}
+
+\begin{code}
+pprModIface :: ModIface -> SDoc
+-- Show a ModIface
+pprModIface iface
+ = vcat [ ptext (sLit "interface")
+ <+> ppr (mi_module iface) <+> pp_boot
+ <+> (if mi_orphan iface then ptext (sLit "[orphan module]") else empty)
+ <+> (if mi_finsts iface then ptext (sLit "[family instance module]") else empty)
+ <+> (if mi_hpc iface then ptext (sLit "[hpc]") else empty)
+ <+> integer opt_HiVersion
+ , nest 2 (text "interface hash:" <+> ppr (mi_iface_hash iface))
+ , nest 2 (text "ABI hash:" <+> ppr (mi_mod_hash iface))
+ , nest 2 (text "export-list hash:" <+> ppr (mi_exp_hash iface))
+ , nest 2 (text "orphan hash:" <+> ppr (mi_orphan_hash iface))
+ , nest 2 (ptext (sLit "where"))
+ , vcat (map pprExport (mi_exports iface))
+ , pprDeps (mi_deps iface)
+ , vcat (map pprUsage (mi_usages iface))
+ , vcat (map pprIfaceAnnotation (mi_anns iface))
+ , pprFixities (mi_fixities iface)
+ , vcat (map pprIfaceDecl (mi_decls iface))
+ , vcat (map ppr (mi_insts iface))
+ , vcat (map ppr (mi_fam_insts iface))
+ , vcat (map ppr (mi_rules iface))
+ , pprVectInfo (mi_vect_info iface)
+ , ppr (mi_warns iface)
+ ]
+ where
+ pp_boot | mi_boot iface = ptext (sLit "[boot]")
+ | otherwise = empty
+\end{code}
+
+When printing export lists, we print like this:
+ Avail f f
+ AvailTC C [C, x, y] C(x,y)
+ AvailTC C [x, y] C!(x,y) -- Exporting x, y but not C
+
+\begin{code}
+pprExport :: IfaceExport -> SDoc
+pprExport (mod, items)
+ = hsep [ ptext (sLit "export"), ppr mod, hsep (map pp_avail items) ]
+ where
+ pp_avail :: GenAvailInfo OccName -> SDoc
+ pp_avail (Avail occ) = ppr occ
+ pp_avail (AvailTC _ []) = empty
+ pp_avail (AvailTC n (n':ns))
+ | n==n' = ppr n <> pp_export ns
+ | otherwise = ppr n <> char '|' <> pp_export (n':ns)
+
+ pp_export [] = empty
+ pp_export names = braces (hsep (map ppr names))
+
+pprUsage :: Usage -> SDoc
+pprUsage usage@UsagePackageModule{}
+ = hsep [ptext (sLit "import"), ppr (usg_mod usage),
+ ppr (usg_mod_hash usage)]
+pprUsage usage@UsageHomeModule{}
+ = hsep [ptext (sLit "import"), ppr (usg_mod_name usage),
+ ppr (usg_mod_hash usage)] $$
+ nest 2 (
+ maybe empty (\v -> text "exports: " <> ppr v) (usg_exports usage) $$
+ vcat [ ppr n <+> ppr v | (n,v) <- usg_entities usage ]
+ )
+
+pprDeps :: Dependencies -> SDoc
+pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs, dep_orphs = orphs,
+ dep_finsts = finsts })
+ = vcat [ptext (sLit "module dependencies:") <+> fsep (map ppr_mod mods),
+ ptext (sLit "package dependencies:") <+> fsep (map ppr pkgs),
+ ptext (sLit "orphans:") <+> fsep (map ppr orphs),
+ ptext (sLit "family instance modules:") <+> fsep (map ppr finsts)
+ ]
+ where
+ ppr_mod (mod_name, boot) = ppr mod_name <+> ppr_boot boot
+ ppr_boot True = text "[boot]"
+ ppr_boot False = empty
+
+pprIfaceDecl :: (Fingerprint, IfaceDecl) -> SDoc
+pprIfaceDecl (ver, decl)
+ = ppr ver $$ nest 2 (ppr decl)
+
+pprFixities :: [(OccName, Fixity)] -> SDoc
+pprFixities [] = empty
+pprFixities fixes = ptext (sLit "fixities") <+> pprWithCommas pprFix fixes
+ where
+ pprFix (occ,fix) = ppr fix <+> ppr occ
+
+pprVectInfo :: IfaceVectInfo -> SDoc
+pprVectInfo (IfaceVectInfo { ifaceVectInfoVar = vars
+ , ifaceVectInfoTyCon = tycons
+ , ifaceVectInfoTyConReuse = tyconsReuse
+ }) =
+ vcat
+ [ ptext (sLit "vectorised variables:") <+> hsep (map ppr vars)
+ , ptext (sLit "vectorised tycons:") <+> hsep (map ppr tycons)
+ , ptext (sLit "vectorised reused tycons:") <+> hsep (map ppr tyconsReuse)
+ ]
+
+instance Outputable Warnings where
+ ppr = pprWarns
+
+pprWarns :: Warnings -> SDoc
+pprWarns NoWarnings = empty
+pprWarns (WarnAll txt) = ptext (sLit "Warn all") <+> ppr txt
+pprWarns (WarnSome prs) = ptext (sLit "Warnings")
+ <+> vcat (map pprWarning prs)
+ where pprWarning (name, txt) = ppr name <+> ppr txt
+
+pprIfaceAnnotation :: IfaceAnnotation -> SDoc
+pprIfaceAnnotation (IfaceAnnotation { ifAnnotatedTarget = target, ifAnnotatedValue = serialized })
+ = ppr target <+> ptext (sLit "annotated by") <+> ppr serialized
+\end{code}