remove conflicting import for nhc98
[haskell-directory.git] / Data / List.hs
index 8b504f7..b006b29 100644 (file)
@@ -35,6 +35,7 @@ module Data.List
    , reverse           -- :: [a] -> [a]
 
    , intersperse       -- :: a -> [a] -> [a]
+   , intercalate       -- :: [a] -> [[a]] -> [a]
    , transpose         -- :: [[a]] -> [[a]]
 
    -- * Reducing lists (folds)
@@ -276,7 +277,7 @@ isSuffixOf x y          =  reverse x `isPrefixOf` reverse y
 -- >isInfixOf "Haskell" "I really like Haskell." -> True
 -- >isInfixOf "Ial" "I really like Haskell." -> False
 isInfixOf               :: (Eq a) => [a] -> [a] -> Bool
-isInfixOf needle haystack = isJust $ find (isPrefixOf needle) (tails haystack)
+isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack)
 
 -- | The 'nub' function removes duplicate elements from a list.
 -- In particular, it keeps only the first occurrence of each element.
@@ -396,6 +397,12 @@ intersperse _   []      = []
 intersperse _   [x]     = [x]
 intersperse sep (x:xs)  = x : sep : intersperse sep xs
 
+-- | 'intercalate' @xs xss@ is equivalent to @('concat' ('intersperse' xs xss))@.
+-- It inserts the list @xs@ in between the lists in @xss@ and concatenates the
+-- result.
+intercalate :: [a] -> [[a]] -> [a]
+intercalate xs xss = concat (intersperse xs xss)
+
 -- | The 'transpose' function transposes the rows and columns of its argument.
 -- For example,
 --