From 6e4d073c7d49c18a1745c00fd7e2d4acfb618504 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 26 Mar 2014 15:38:02 +0900 Subject: [PATCH] using dropWhileEnd (#193). --- Language/Haskell/GhcMod/Cradle.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Language/Haskell/GhcMod/Cradle.hs b/Language/Haskell/GhcMod/Cradle.hs index 780ff71..269fe26 100644 --- a/Language/Haskell/GhcMod/Cradle.hs +++ b/Language/Haskell/GhcMod/Cradle.hs @@ -112,7 +112,10 @@ getPackageDbDir sconf = do return path where parse = head . filter ("package-db:" `isPrefixOf`) . lines - extractValue = fst . break isSpace . dropWhile isSpace . drop pkgDbKeyLen + extractValue = dropWhileEnd isSpace . dropWhile isSpace . drop pkgDbKeyLen + -- 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) [] -- | Adding necessary GHC options to the package db. -- Exception is thrown if the string argument is incorrect.