Document UniqSet
[ghc-hetmet.git] / compiler / utils / Util.lhs
index 82e0393..5d84721 100644 (file)
@@ -6,7 +6,7 @@
 
 \begin{code}
 module Util (
-        debugIsOn, ghciTablesNextToCode, picIsOn,
+        ghciSupported, debugIsOn, ghciTablesNextToCode, picIsOn,
         isWindowsHost, isWindowsTarget, isDarwinTarget,
 
         -- general list processing
@@ -65,8 +65,6 @@ module Util (
         doesDirNameExist,
         modificationTimeIfExists,
 
-        later, handleDyn, handle,
-
         -- Filename utils
         Suffix,
         splitLongestPrefix,
@@ -79,9 +77,6 @@ module Util (
 
 import Panic
 
-import Control.Exception ( Exception(..), finally, catchDyn, throw )
-import qualified Control.Exception as Exception
-import Data.Dynamic     ( Typeable )
 import Data.IORef       ( IORef, newIORef )
 import System.IO.Unsafe ( unsafePerformIO )
 import Data.IORef       ( readIORef, writeIORef )
@@ -94,7 +89,7 @@ import FastTypes
 #endif
 
 import Control.Monad    ( unless )
-import SYSTEM_IO_ERROR as IO ( catch, isDoesNotExistError )
+import System.IO.Error as IO ( catch, isDoesNotExistError )
 import System.Directory ( doesDirectoryExist, createDirectory,
                           getModificationTime )
 import System.FilePath hiding ( searchPathSeparator )
@@ -107,11 +102,18 @@ infixr 9 `thenCmp`
 
 %************************************************************************
 %*                                                                      *
-\subsection{Is DEBUG on, are we on Windows?}
+\subsection{Is DEBUG on, are we on Windows, etc?}
 %*                                                                      *
 %************************************************************************
 
 \begin{code}
+ghciSupported :: Bool
+#ifdef GHCI
+ghciSupported = True
+#else
+ghciSupported = False
+#endif
+
 debugIsOn :: Bool
 #ifdef DEBUG
 debugIsOn = True
@@ -405,16 +407,6 @@ isn'tIn msg x ys
 # endif /* DEBUG */
 \end{code}
 
-foldl1' was added in GHC 6.4
-
-\begin{code}
-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 604
-foldl1'          :: (a -> a -> a) -> [a] -> a
-foldl1' f (x:xs) =  foldl' f x xs
-foldl1' _ []     =  panic "foldl1'"
-#endif
-\end{code}
-
 %************************************************************************
 %*                                                                      *
 \subsubsection[Utils-Carsten-mergesort]{A mergesort from Carsten}
@@ -826,20 +818,6 @@ doesDirNameExist fpath = case takeDirectory fpath of
                          "" -> return True -- XXX Hack
                          _  -> doesDirectoryExist (takeDirectory fpath)
 
--- -----------------------------------------------------------------------------
--- Exception utils
-
-later :: IO b -> IO a -> IO a
-later = flip finally
-
-handleDyn :: Typeable ex => (ex -> IO a) -> IO a -> IO a
-handleDyn = flip catchDyn
-
-handle :: (Exception -> IO a) -> IO a -> IO a
-handle h f = f `Exception.catch` \e -> case e of
-    ExitException _ -> throw e
-    _               -> h e
-
 -- --------------------------------------------------------------
 -- check existence & modification time at the same time