X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;h=5cf020f7f56929ed598f33f44977e28e493182b4;hp=af811104762c0fb7fc99252ee6755dc2a9945514;hb=4fa44a3ae9c36222ccb460ba3ed24e46bf7c70ae;hpb=1c15bee5a8fc004c16693d7d7a2d95b442549b66 diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index af81110..5cf020f 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -42,7 +42,7 @@ module Util ( -- * Comparisons isEqual, eqListBy, - thenCmp, cmpList, maybePrefixMatch, + thenCmp, cmpList, removeSpaces, -- * Transitive closures @@ -65,7 +65,7 @@ module Util ( doesDirNameExist, modificationTimeIfExists, - global, consIORef, + global, consIORef, globalMVar, globalEmptyMVar, -- * Filenames and paths Suffix, @@ -83,10 +83,10 @@ import Data.IORef ( IORef, newIORef ) import System.IO.Unsafe ( unsafePerformIO ) import Data.IORef ( readIORef, writeIORef ) import Data.List hiding (group) +import Control.Concurrent.MVar ( MVar, newMVar, newEmptyMVar ) -import qualified Data.List as List ( elem ) #ifdef DEBUG -import qualified Data.List as List ( notElem ) +import qualified Data.List as List ( elem, notElem ) import FastTypes #endif @@ -665,15 +665,6 @@ cmpList cmp (a:as) (b:bs) \end{code} \begin{code} --- This (with a more general type) is Data.List.stripPrefix from GHC 6.8. --- This definition can be removed once we require at least 6.8 to build. -maybePrefixMatch :: String -> String -> Maybe String -maybePrefixMatch [] rest = Just rest -maybePrefixMatch (_:_) [] = Nothing -maybePrefixMatch (p:pat) (r:rest) - | p == r = maybePrefixMatch pat rest - | otherwise = Nothing - removeSpaces :: String -> String removeSpaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace \end{code} @@ -709,6 +700,14 @@ consIORef var x = do writeIORef var (x:xs) \end{code} +\begin{code} +globalMVar :: a -> MVar a +globalMVar a = unsafePerformIO (newMVar a) + +globalEmptyMVar :: MVar a +globalEmptyMVar = unsafePerformIO newEmptyMVar +\end{code} + Module names: \begin{code}