\begin{code}
module Util (
- debugIsOn, ghciTablesNextToCode,
+ ghciSupported, debugIsOn, ghciTablesNextToCode, picIsOn,
isWindowsHost, isWindowsTarget, isDarwinTarget,
-- general list processing
doesDirNameExist,
modificationTimeIfExists,
- later, handleDyn, handle,
-
-- Filename utils
Suffix,
splitLongestPrefix,
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 )
#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 )
%************************************************************************
%* *
-\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
ghciTablesNextToCode = False
#endif
+picIsOn :: Bool
+#ifdef __PIC__
+picIsOn = True
+#else
+picIsOn = False
+#endif
+
isWindowsHost :: Bool
#ifdef mingw32_HOST_OS
isWindowsHost = True
# 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}
"" -> 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