Remove prefixMatch and suffixMatch from Util
authorIan Lynagh <igloo@earth.li>
Mon, 2 Jul 2007 11:42:08 +0000 (11:42 +0000)
committerIan Lynagh <igloo@earth.li>
Mon, 2 Jul 2007 11:42:08 +0000 (11:42 +0000)
Use standard isPrefixOf/isSuffixOf instead.

compiler/ghci/InteractiveUI.hs
compiler/main/DynFlags.hs
compiler/main/Main.hs
compiler/main/StaticFlags.hs
compiler/utils/Util.lhs

index e1c9231..3f87d3c 100644 (file)
@@ -628,7 +628,7 @@ lookupCommand str = do
   -- look for exact match first, then the first prefix match
   case [ c | c <- cmds, str == cmdName c ] of
      c:_ -> return (Just c)
-     [] -> case [ c | c@(s,_,_,_) <- cmds, prefixMatch str s ] of
+     [] -> case [ c | c@(s,_,_,_) <- cmds, str `isPrefixOf` s ] of
                [] -> return Nothing
                c:_ -> return (Just c)
 
index a5c1ab8..8509ffc 100644 (file)
@@ -1429,7 +1429,7 @@ machdepCCOpts dflags
               sta = opt_Static
           in
                    ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else ""
---                    , if suffixMatch "mingw32" cTARGETPLATFORM then "-mno-cygwin" else "" 
+--                    , if "mingw32" `isSuffixOf` cTARGETPLATFORM then "-mno-cygwin" else "" 
                      ],
                      [ "-fno-defer-pop",
 #ifdef HAVE_GCC_MNO_OMIT_LFPTR
index e9c8343..428f42e 100644 (file)
@@ -70,7 +70,7 @@ main =
   argv0 <- getArgs
 
   let
-        (minusB_args, argv1) = partition (prefixMatch "-B") argv0
+        (minusB_args, argv1) = partition ("-B" `isPrefixOf`) argv0
         mbMinusB | null minusB_args = Nothing
                  | otherwise = Just (drop 2 (last minusB_args))
 
index 9e13360..a162214 100644 (file)
@@ -85,7 +85,7 @@ import Data.IORef
 import System.IO.Unsafe        ( unsafePerformIO )
 import Control.Monad   ( when )
 import Data.Char       ( isDigit )
-import Data.List       ( sort, intersperse, nub )
+import Data.List
 
 -----------------------------------------------------------------------------
 -- Static flags
@@ -369,7 +369,7 @@ isStaticFlag f =
        "fPIC",
        "fhpc"
        ]
-  || any (flip prefixMatch f) [
+  || any (`isPrefixOf` f) [
        "fliberate-case-threshold",
        "fmax-worker-args",
        "fhistory-size",
index 39fd64b..2d80c45 100644 (file)
@@ -39,7 +39,7 @@ module Util (
 
        -- comparisons
        isEqual, eqListBy, 
-       thenCmp, cmpList, prefixMatch, suffixMatch, maybePrefixMatch,
+       thenCmp, cmpList, maybePrefixMatch,
        removeSpaces,
 
        -- strictness
@@ -688,12 +688,6 @@ cmpList cmp (a:as) (b:bs)
 \end{code}
 
 \begin{code}
-prefixMatch :: Eq a => [a] -> [a] -> Bool
-prefixMatch [] _str = True
-prefixMatch _pat [] = False
-prefixMatch (p:ps) (s:ss) | p == s    = prefixMatch ps ss
-                         | otherwise = False
-
 maybePrefixMatch :: String -> String -> Maybe String
 maybePrefixMatch []    rest = Just rest
 maybePrefixMatch (_:_) []   = Nothing
@@ -701,9 +695,6 @@ maybePrefixMatch (p:pat) (r:rest)
   | p == r    = maybePrefixMatch pat rest
   | otherwise = Nothing
 
-suffixMatch :: Eq a => [a] -> [a] -> Bool
-suffixMatch pat str = prefixMatch (reverse pat) (reverse str)
-
 removeSpaces :: String -> String
 removeSpaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
 \end{code}