@@ -23,7 +23,9 @@ main = do
23 pkgDirName p =
23 pkgDirName p =
24 if countDashes p < 2
24 if countDashes p < 2
25 then error $ p ++ " not in name-version-hash format"
25 then error $ p ++ " not in name-version-hash format"
26+ else let nv_ = dropEnd 22 p in
26− else (removeDashSegment . removeDashSegment) p
27+ if last nv_ == '-' then removeDashSegment $ init nv_
28+ else error $ p ++ " not in name-version-hash format"
28 countDashes = length . filter (== '-')
30 countDashes = length . filter (== '-')
@@ -47,3 +49,9 @@ main = do
47 return $ map fst $ sortBy compareSnd fileTimes
49 return $ map fst $ sortBy compareSnd fileTimes
49 compareSnd (_,t1) (_,t2) = compare t1 t2
51 compareSnd (_,t1) (_,t2) = compare t1 t2
53+-- from Data.List.Extra
54+dropEnd :: Int -> [a] -> [a]
55+dropEnd i xs = f xs (drop i xs)
56+ where f (x:xs) (y:ys) = x : f xs ys