+ = LM ModuleName [Unlinked]
+ | LP PackageName
+
+instance Outputable Linkable where
+ ppr (LM mod_nm unlinkeds) = text "LinkableM" <+> ppr mod_nm <+> ppr unlinkeds
+ ppr (LP package_nm) = text "LinkableP" <+> ptext package_nm
+
+emptyPLS :: IO PersistentLinkerState
+emptyPLS = return (PersistentLinkerState { closure_env = emptyFM,
+ itbl_env = emptyFM })
+\end{code}
+
+\begin{code}
+link :: PackageConfigInfo
+ -> [SCC Linkable]
+ -> PersistentLinkerState
+ -> IO LinkResult
+
+#ifndef GHCI_NOTYET
+--link = panic "CmLink.link: not implemented"
+link pci groups pls1
+ = do putStrLn "Hello from the Linker!"
+ putStrLn (showSDoc (vcat (map ppLinkableSCC groups)))
+ putStrLn "Bye-bye from the Linker!"
+ return (LinkOK pls1)
+
+ppLinkableSCC :: SCC Linkable -> SDoc
+ppLinkableSCC = ppr . flattenSCC
+
+#else
+
+
+link pci [] pls = return (LinkOK pls)
+link pci (groupSCC:groups) pls = do
+ let group = flattenSCC groupSCC
+ -- the group is either all objects or all interpretable, for now
+ if all isObject group
+ then do mapM loadObj [ file | DotO file <- group ]
+ resolveObjs
+ link pci groups pls
+ else if all isInterpretable group
+ then do (new_closure_env, new_itbl_env) <-
+ linkIModules (closure_env pls)
+ (itbl_env pls)
+ [ trees | Trees trees <- group ]
+ link pci groups (PersistentLinkerState{
+ closure_env=new_closure_env,
+ itbl_env=new_itbl_env})
+ else
+ return (LinkErrs pls (ptext SLIT("linker: group must contain all objects or all interpreted modules")))
+#endif
+