Commit 316b3cd4 authored by EyalLotem's avatar EyalLotem

Use Data.List ( intercalate ) which is exported for more than the last 3 years...

Use Data.List ( intercalate ) which is exported for more than the last 3 years instead of reimplementing it all over the place
parent dce9d97a
......@@ -50,7 +50,7 @@ module Distribution.GetOpt (
-- $example
) where
import Data.List ( isPrefixOf, intersperse, find )
import Data.List ( isPrefixOf, intercalate, find )
-- |What to do with options following non-options
data ArgOrder a
......@@ -98,7 +98,7 @@ usageInfo :: String -- header
-> [OptDescr a] -- option descriptors
-> String -- nicely formatted decription of options
usageInfo header optDescr = unlines (header:table)
where (ss,ls,ds) = unzip3 [ (sepBy ", " (map (fmtShort ad) sos)
where (ss,ls,ds) = unzip3 [ (intercalate ", " (map (fmtShort ad) sos)
,concatMap (fmtLong ad) (take 1 los)
,d)
| Option sos los ad d <- optDescr ]
......@@ -111,7 +111,6 @@ usageInfo header optDescr = unlines (header:table)
| (so,lo,d) <- zip3 ss ls ds
, (so',lo',d') <- fmtOpt dsWidth so lo d ]
padTo n x = take n (x ++ repeat ' ')
sepBy s = concat . intersperse s
fmtOpt :: Int -> String -> String -> String -> [(String, String, String)]
fmtOpt descrWidth so lo descr =
......
......@@ -57,7 +57,7 @@ import qualified Data.Char as Char
import System.FilePath
( pathSeparator )
import Data.List
( intersperse )
( intercalate, intersperse )
-- | A valid Haskell module name.
--
......@@ -127,4 +127,4 @@ components (ModuleName ms) = ms
-- > toFilePath (fromString "A.B.C") = "A/B/C"
--
toFilePath :: ModuleName -> FilePath
toFilePath = concat . intersperse [pathSeparator] . components
toFilePath = intercalate [pathSeparator] . components
......@@ -73,7 +73,7 @@ import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>), (<+>), text)
import Control.DeepSeq (NFData(..))
import qualified Data.Char as Char ( isDigit, isAlphaNum )
import Data.List ( intersperse )
import Data.List ( intercalate )
import Data.Typeable ( Typeable )
newtype PackageName = PackageName String
......@@ -83,7 +83,7 @@ instance Text PackageName where
disp (PackageName n) = Disp.text n
parse = do
ns <- Parse.sepBy1 component (Parse.char '-')
return (PackageName (concat (intersperse "-" ns)))
return (PackageName (intercalate "-" ns))
where
component = do
cs <- Parse.munch1 Char.isAlphaNum
......
......@@ -124,7 +124,7 @@ module Distribution.PackageDescription (
knownRepoTypes,
) where
import Data.List (nub, intersperse)
import Data.List (nub, intercalate)
import Data.Maybe (maybeToList)
import Data.Monoid (Monoid(mempty, mappend))
import Data.Typeable ( Typeable )
......@@ -440,7 +440,7 @@ instance Monoid TestSuite where
testName = combine' testName,
testInterface = combine testInterface,
testBuildInfo = combine testBuildInfo,
testEnabled = if testEnabled a then True else testEnabled b
testEnabled = testEnabled a || testEnabled b
}
where combine field = field a `mappend` field b
combine' f = case (f a, f b) of
......@@ -493,7 +493,7 @@ stdParse f = do
cs <- Parse.sepBy1 component (Parse.char '-')
_ <- Parse.char '-'
ver <- parse
let name = concat (intersperse "-" cs)
let name = intercalate "-" cs
return $! f ver (lowercase name)
where
component = do
......
......@@ -139,7 +139,7 @@ import System.IO.Error (isDoesNotExistError)
import Distribution.Compat.Exception (catchIO, throwIOIO)
import Control.Monad (when)
import Data.List (intersperse, unionBy, nub, (\\))
import Data.List (intercalate, unionBy, nub, (\\))
-- | A simple implementation of @main@ for a Cabal setup script.
-- It reads the package description file using IO, and performs the
......@@ -187,7 +187,7 @@ defaultMainHelper hooks args = topHandler $
printHelp help = getProgName >>= putStr . help
printOptionsList = putStr . unlines
printErrors errs = do
putStr (concat (intersperse "\n" errs))
putStr (intercalate "\n" errs)
exitWith (ExitFailure 1)
printNumericVersion = putStrLn $ display cabalVersion
printVersion = putStrLn $ "Cabal library version "
......
......@@ -146,7 +146,7 @@ import Control.Concurrent.MVar
( newEmptyMVar, putMVar, takeMVar )
#endif
import Data.List
( nub, unfoldr, isPrefixOf, tails, intersperse )
( nub, unfoldr, isPrefixOf, tails, intercalate )
import Data.Char as Char
( toLower, chr, ord )
import Data.Bits
......@@ -1163,8 +1163,5 @@ comparing p x y = p x `compare` p y
isInfixOf :: String -> String -> Bool
isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack)
intercalate :: [a] -> [[a]] -> [a]
intercalate sep = concat . intersperse sep
lowercase :: String -> String
lowercase = map Char.toLower
......@@ -31,7 +31,7 @@ import Data.Time
( getCurrentTime, utcToLocalTime, toGregorian, localDay, getCurrentTimeZone )
import Data.List
( intersperse, intercalate, nub, groupBy, (\\) )
( intercalate, nub, groupBy, (\\) )
import Data.Maybe
( fromMaybe, isJust, catMaybes )
import Data.Function
......@@ -714,7 +714,7 @@ generateCabalFile fileName c =
listField = listFieldS . fmap (map display)
listFieldS :: Maybe [String] -> Flag String
listFieldS = Flag . maybe "" (concat . intersperse ", ")
listFieldS = Flag . maybe "" (intercalate ", ")
field :: Text t => String -> Flag t -> Maybe String -> Bool -> Doc
field s f = fieldS s (fmap display f)
......
......@@ -96,7 +96,7 @@ import System.Environment (getArgs, getProgName)
import System.Exit (exitFailure)
import System.FilePath (splitExtension, takeExtension)
import System.Directory (doesFileExist)
import Data.List (intersperse)
import Data.List (intercalate)
import Data.Monoid (Monoid(..))
import Control.Monad (when, unless)
......@@ -131,7 +131,7 @@ mainWorker args = topHandler $
putStr $ "\nYou can edit the cabal configuration file to set defaults:\n"
++ " " ++ configFile ++ "\n"
printOptionsList = putStr . unlines
printErrors errs = die $ concat (intersperse "\n" errs)
printErrors errs = die $ intercalate "\n" errs
printNumericVersion = putStrLn $ display Paths_cabal_install.version
printVersion = putStrLn $ "cabal-install version "
++ display Paths_cabal_install.version
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment