Use standard isPrefixOf/isSuffixOf instead.
-- 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)
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
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))
import System.IO.Unsafe ( unsafePerformIO )
import Control.Monad ( when )
import Data.Char ( isDigit )
-import Data.List ( sort, intersperse, nub )
+import Data.List
-----------------------------------------------------------------------------
-- Static flags
"fPIC",
"fhpc"
]
- || any (flip prefixMatch f) [
+ || any (`isPrefixOf` f) [
"fliberate-case-threshold",
"fmax-worker-args",
"fhistory-size",
-- comparisons
isEqual, eqListBy,
- thenCmp, cmpList, prefixMatch, suffixMatch, maybePrefixMatch,
+ thenCmp, cmpList, maybePrefixMatch,
removeSpaces,
-- strictness
\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
| 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}