From 3c8fea85fbca46254cc398664a7e378c933e71c0 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Sat, 19 Apr 2014 15:20:16 +0900 Subject: [PATCH] dropWhileEnd moves to Utils. --- Language/Haskell/GhcMod/GhcPkg.hs | 10 ++++------ Language/Haskell/GhcMod/Utils.hs | 4 ++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Language/Haskell/GhcMod/GhcPkg.hs b/Language/Haskell/GhcMod/GhcPkg.hs index d38eb39..eee9998 100644 --- a/Language/Haskell/GhcMod/GhcPkg.hs +++ b/Language/Haskell/GhcMod/GhcPkg.hs @@ -18,10 +18,11 @@ import Data.Char (isSpace,isAlphaNum) import Data.List (isPrefixOf, intercalate) import Data.Maybe (listToMaybe, maybeToList) import Language.Haskell.GhcMod.Types -import System.FilePath (()) -import System.Process (readProcessWithExitCode) -import System.IO (hPutStrLn,stderr) +import Language.Haskell.GhcMod.Utils import System.Exit (ExitCode(..)) +import System.FilePath (()) +import System.IO (hPutStrLn,stderr) +import System.Process (readProcessWithExitCode) import Text.ParserCombinators.ReadP (ReadP, char, between, sepBy1, many1, string, choice, eof) import qualified Text.ParserCombinators.ReadP as P @@ -48,9 +49,6 @@ getSandboxDbDir sconf = do parse = head . filter (key `isPrefixOf`) . lines extractValue = dropWhileEnd isSpace . dropWhile isSpace . drop keyLen - -- dropWhileEnd is not provided prior to base 4.5.0.0. - dropWhileEnd :: (a -> Bool) -> [a] -> [a] - dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) [] getPackageDbStack :: FilePath -- ^ Project Directory (where the -- cabal.sandbox.config file would be if it diff --git a/Language/Haskell/GhcMod/Utils.hs b/Language/Haskell/GhcMod/Utils.hs index 00de5bc..33af425 100644 --- a/Language/Haskell/GhcMod/Utils.hs +++ b/Language/Haskell/GhcMod/Utils.hs @@ -1 +1,5 @@ module Language.Haskell.GhcMod.Utils where + +-- dropWhileEnd is not provided prior to base 4.5.0.0. +dropWhileEnd :: (a -> Bool) -> [a] -> [a] +dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []