+ = hPutCol if_hdl upp_fixity fixities
+
+ifaceRules if_hdl rules emitted
+ | null orphan_rule_pretties && null local_id_pretties
+ = return ()
+ | otherwise
+ = do printForIface if_hdl (vcat [
+ ptext SLIT("{-## __R"),
+
+ vcat orphan_rule_pretties,
+
+ vcat local_id_pretties,
+
+ ptext SLIT("##-}")
+ ])
+
+ return ()
+ where
+ orphan_rule_pretties = [ pprCoreRule (Just fn) rule <+> semi
+ | ProtoCoreRule _ fn rule <- rules
+ ]
+ local_id_pretties = [ pprCoreRule (Just fn) rule <+> semi
+ | fn <- varSetElems emitted,
+ rule <- rulesRules (getIdSpecialisation fn),
+ all (`elemVarSet` emitted) (varSetElems (ruleSomeLhsFreeVars interestingId rule))
+ -- Spit out a rule only if all its lhs free vars are eemitted
+ ]
+\end{code}