-import IdInfo ( StrictnessInfo, ArityInfo,
- arityInfo, ppArityInfo, strictnessInfo, ppStrictnessInfo,
- getWorkerId_maybe, bottomIsGuaranteed, IdInfo
- )
-import CoreSyn ( SYN_IE(CoreExpr), SYN_IE(CoreBinding), GenCoreExpr, GenCoreBinding(..) )
-import CoreUnfold ( calcUnfoldingGuidance, UnfoldingGuidance(..), Unfolding )
-import FreeVars ( addExprFVs )
-import Name ( isLocallyDefined, isWiredInName, modAndOcc, getName, nameModule, pprOccName,
- OccName, occNameString, nameOccName, nameString, isExported,
- Name {-instance NamedThing-}, Provenance, NamedThing(..)
- )
-import TyCon ( TyCon(..) {-instance NamedThing-} )
-import Class ( GenClass(..){-instance NamedThing-}, SYN_IE(Class), GenClassOp,
- classOpLocalType, classSig )
-import FieldLabel ( FieldLabel{-instance NamedThing-},
- fieldLabelName, fieldLabelType )
-import Type ( mkSigmaTy, mkDictTy, getAppTyCon,
- mkTyVarTy, SYN_IE(Type)
- )
-import TyVar ( GenTyVar {- instance Eq -} )
-import Unique ( Unique {- instance Eq -} )
-
-import PprEnv -- not sure how much...
-import Outputable ( PprStyle(..), Outputable(..) )
-import PprType
-import PprCore ( pprIfaceUnfolding )
-import Pretty
-import Outputable ( printDoc )
-
-
-import Bag ( bagToList, isEmptyBag )
-import Maybes ( catMaybes, maybeToBool )
-import FiniteMap ( emptyFM, addToFM, addToFM_C, lookupFM, fmToList, eltsFM, FiniteMap )
-import UniqFM ( UniqFM, lookupUFM, listToUFM )
-import Util ( sortLt, zipWithEqual, zipWith3Equal, mapAccumL,
- assertPanic, panic{-ToDo:rm-}, pprTrace,
- pprPanic
- )
-\end{code}
-
-We have a function @startIface@ to open the output file and put
-(something like) ``interface Foo'' in it. It gives back a handle
-for subsequent additions to the interface file.
-
-We then have one-function-per-block-of-interface-stuff, e.g.,
-@ifaceExportList@ produces the @__exports__@ section; it appends
-to the handle provided by @startIface@.
-
-\begin{code}
-startIface :: Module
- -> IO (Maybe Handle) -- Nothing <=> don't do an interface
-
-ifaceMain :: Maybe Handle
- -> InterfaceDetails
- -> IO ()
-
-
-ifaceDecls :: Maybe Handle
- -> [TyCon] -> [Class]
- -> Bag InstInfo
- -> [Id] -- Ids used at code-gen time; they have better pragma info!
- -> [CoreBinding] -- In dependency order, later depend on earlier
- -> IO ()
-
-endIface :: Maybe Handle -> IO ()
-\end{code}
-
-\begin{code}
-startIface mod
- = case opt_ProduceHi of
- Nothing -> return Nothing -- not producing any .hi file
- Just fn ->
- openFile fn WriteMode >>= \ if_hdl ->
- hPutStr if_hdl ("{-# GHC_PRAGMA INTERFACE VERSION 20 #-}\n_interface_ "++ _UNPK_ mod ++ "\n") >>
- return (Just if_hdl)
-
-endIface Nothing = return ()
-endIface (Just if_hdl) = hPutStr if_hdl "\n" >> hClose if_hdl
-\end{code}
-
-
-\begin{code}
-ifaceMain Nothing iface_stuff = return ()
-ifaceMain (Just if_hdl)
- (import_usages, ExportEnv avails fixities, instance_modules)
- =
- ifaceInstanceModules if_hdl instance_modules >>
- ifaceUsages if_hdl import_usages >>
- ifaceExports if_hdl avails >>
- ifaceFixities if_hdl fixities >>
- return ()
-
-ifaceDecls Nothing tycons classes inst_info final_ids simplified = return ()
-ifaceDecls (Just hdl)
- tycons classes
- inst_infos
- final_ids binds
- | null_decls = return ()
- -- You could have a module with just (re-)exports/instances in it
- | otherwise
- = ifaceInstances hdl inst_infos >>= \ needed_ids ->
- hPutStr hdl "_declarations_\n" >>
- ifaceClasses hdl classes >>
- ifaceTyCons hdl tycons >>
- ifaceBinds hdl needed_ids final_ids binds >>
- return ()
- where
- null_decls = null binds &&
- null tycons &&
- null classes &&
- isEmptyBag inst_infos