From ec0067142368dbf1ac92f8ba056043d52e41af8b Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Tue, 22 Jan 2019 01:14:10 +0100 Subject: Add Stack version check for `stack ide packages --cabal-file` --- src/CabalHelper/Shared/Common.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/CabalHelper/Shared/Common.hs') diff --git a/src/CabalHelper/Shared/Common.hs b/src/CabalHelper/Shared/Common.hs index 4165ab0..2d4b037 100644 --- a/src/CabalHelper/Shared/Common.hs +++ b/src/CabalHelper/Shared/Common.hs @@ -104,6 +104,9 @@ parsePkgId bs = parseVer :: String -> Version parseVer vers = runReadP parseVersion vers +parseVerMay :: String -> Maybe Version +parseVerMay vers = runReadPMay parseVersion vers + trim :: String -> String trim = dropWhileEnd isSpace @@ -114,9 +117,16 @@ sameMajorVersionAs :: Version -> Version -> Bool sameMajorVersionAs a b = majorVer a == majorVer b runReadP :: ReadP t -> String -> t -runReadP p i = case filter ((=="") . snd) $ readP_to_S p i of - (a,""):[] -> a - _ -> error $ "Error parsing: " ++ show i +runReadP p i = + case runReadPMay p i of + Just x -> x + Nothing -> error $ "Error parsing version: " ++ show i + +runReadPMay :: ReadP t -> String -> Maybe t +runReadPMay p i = case filter ((=="") . snd) $ readP_to_S p i of + (a,""):[] -> Just a + _ -> Nothing + appCacheDir :: IO FilePath appCacheDir = -- cgit v1.2.3