Convert more UniqFM's back to LazyUniqFM's
[ghc-hetmet.git] / compiler / ghci / Linker.lhs
index 6f000c5..892171c 100644 (file)
@@ -14,11 +14,11 @@ necessary.
 \begin{code}
 {-# OPTIONS -optc-DNON_POSIX_SOURCE -#include "Linker.h" #-}
 
-{-# OPTIONS_GHC -w #-}
+{-# OPTIONS -w #-}
 -- The above warning supression flag is a temporary kludge.
 -- While working on this module you are encouraged to remove it and fix
 -- any warnings in the module. See
---     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
 -- for details
 
 module Linker ( HValue, getHValue, showLinkerState,
@@ -47,7 +47,7 @@ import Name
 import NameEnv
 import NameSet
 import qualified OccName
-import UniqFM
+import LazyUniqFM
 import Module
 import ListSetOps
 import DynFlags
@@ -73,6 +73,7 @@ import Data.IORef
 import Data.List
 import Foreign
 
+import System.FilePath
 import System.IO
 import System.Directory
 
@@ -171,7 +172,7 @@ deleteFromLinkEnv to_remove
 
 dataConInfoPtrToName :: Ptr () -> TcM (Either String Name)
 dataConInfoPtrToName x = do 
-   theString <- ioToTcRn $ do
+   theString <- liftIO $ do
       let ptr = castPtr x :: Ptr StgInfoTable
       conDescAddress <- getConDescAddress ptr 
       peekArray0 0 conDescAddress  
@@ -657,7 +658,7 @@ getLinkDeps hsc_env hpt pit maybe_normal_osuf span mods
                        return lnk
 
            adjust_ul osuf (DotO file) = do
-               let new_file = replaceFilenameSuffix file osuf
+               let new_file = replaceExtension file osuf
                ok <- doesFileExist new_file
                if (not ok)
                   then dieWith span $
@@ -1080,8 +1081,8 @@ locateOneObj dirs lib
                        Just lib_path -> return (DLL (lib ++ "-ghc" ++ cProjectVersion))
                        Nothing       -> return (DLL lib) }}            -- We assume
    where
-     mk_obj_path dir = dir `joinFileName` (lib `joinFileExt` "o")
-     mk_dyn_lib_path dir = dir `joinFileName` mkSOName (lib ++ "-ghc" ++ cProjectVersion)
+     mk_obj_path dir = dir </> lib <.> "o"
+     mk_dyn_lib_path dir = dir </> mkSOName (lib ++ "-ghc" ++ cProjectVersion)
 #else
 -- When the GHC package was compiled as dynamic library (=__PIC__ set),
 -- we search for .so libraries first.
@@ -1096,8 +1097,8 @@ locateOneObj dirs lib
                        Just obj_path -> return (Object obj_path)
                        Nothing       -> return (DLL lib) }}            -- We assume
    where
-     mk_obj_path dir = dir `joinFileName` (lib `joinFileExt` "o")
-     mk_dyn_lib_path dir = dir `joinFileName` mkSOName (lib ++ "-ghc" ++ cProjectVersion)
+     mk_obj_path dir = dir </> (lib <.> "o")
+     mk_dyn_lib_path dir = dir </> mkSOName (lib ++ "-ghc" ++ cProjectVersion)
 #endif
 
 -- ----------------------------------------------------------------------------
@@ -1112,16 +1113,16 @@ loadDynamic paths rootname
                        -- Tried all our known library paths, so let 
                        -- dlopen() search its own builtin paths now.
   where
-    mk_dll_path dir = dir `joinFileName` mkSOName rootname
+    mk_dll_path dir = dir </> mkSOName rootname
 
 #if defined(darwin_TARGET_OS)
-mkSOName root = ("lib" ++ root) `joinFileExt` "dylib"
+mkSOName root = ("lib" ++ root) <.> "dylib"
 #elif defined(mingw32_TARGET_OS)
 -- Win32 DLLs have no .dll extension here, because addDLL tries
 -- both foo.dll and foo.drv
 mkSOName root = root
 #else
-mkSOName root = ("lib" ++ root) `joinFileExt` "so"
+mkSOName root = ("lib" ++ root) <.> "so"
 #endif
 
 -- Darwin / MacOS X only: load a framework
@@ -1129,15 +1130,20 @@ mkSOName root = ("lib" ++ root) `joinFileExt` "so"
 -- name. They are searched for in different paths than normal libraries.
 #ifdef darwin_TARGET_OS
 loadFramework extraPaths rootname
-   = do        { mb_fwk <- findFile mk_fwk (extraPaths ++ defaultFrameworkPaths)
-       ; case mb_fwk of
-           Just fwk_path -> loadDLL fwk_path
-           Nothing       -> return (Just "not found") }
-               -- Tried all our known library paths, but dlopen()
-               -- has no built-in paths for frameworks: give up
+   = do { either_dir <- Control.Exception.try getHomeDirectory
+        ; let homeFrameworkPath = case either_dir of
+                                  Left _ -> []
+                                  Right dir -> [dir ++ "/Library/Frameworks"]
+              ps = extraPaths ++ homeFrameworkPath ++ defaultFrameworkPaths
+        ; mb_fwk <- findFile mk_fwk ps
+        ; case mb_fwk of
+            Just fwk_path -> loadDLL fwk_path
+            Nothing       -> return (Just "not found") }
+                -- Tried all our known library paths, but dlopen()
+                -- has no built-in paths for frameworks: give up
    where
-     mk_fwk dir = dir `joinFileName` (rootname ++ ".framework/" ++ rootname)
-       -- sorry for the hardcoded paths, I hope they won't change anytime soon:
+     mk_fwk dir = dir </> (rootname ++ ".framework/" ++ rootname)
+        -- sorry for the hardcoded paths, I hope they won't change anytime soon:
      defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
 #endif
 \end{code}