module Distribution.Simple.Program.Internal (
stripExtractVersion,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.Generic(safeTail)
stripExtractVersion :: String -> String
String
str =
let numeric :: String -> Bool
numeric String
"" = Bool
False
numeric (Char
x:String
_) = Char -> Bool
isDigit Char
x
filterPar' :: Int -> [String] -> [String]
filterPar' :: Int -> [String] -> [String]
filterPar' Int
_ [] = []
filterPar' Int
n (String
x:[String]
xs)
| Int
n forall a. Ord a => a -> a -> Bool
>= Int
0 Bool -> Bool -> Bool
&& String
"(" forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
x = Int -> [String] -> [String]
filterPar' (Int
nforall a. Num a => a -> a -> a
+Int
1) ((forall a. [a] -> [a]
safeTail String
x)forall a. a -> [a] -> [a]
:[String]
xs)
| Int
n forall a. Ord a => a -> a -> Bool
> Int
0 Bool -> Bool -> Bool
&& String
")" forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` String
x = Int -> [String] -> [String]
filterPar' (Int
nforall a. Num a => a -> a -> a
-Int
1) [String]
xs
| Int
n forall a. Ord a => a -> a -> Bool
> Int
0 = Int -> [String] -> [String]
filterPar' Int
n [String]
xs
| Bool
otherwise = String
xforall a. a -> [a] -> [a]
:Int -> [String] -> [String]
filterPar' Int
n [String]
xs
filterPar :: [String] -> [String]
filterPar = Int -> [String] -> [String]
filterPar' Int
0
in case forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bool
numeric) ([String] -> [String]
filterPar forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
words forall a b. (a -> b) -> a -> b
$ String
str) of
(String
ver:[String]
_) ->
let isDot :: Char -> Bool
isDot = (forall a. Eq a => a -> a -> Bool
== Char
'.')
(String
major, String
rest) = forall a. (a -> Bool) -> [a] -> ([a], [a])
break Char -> Bool
isDot String
ver
minor :: String
minor = forall a. (a -> Bool) -> [a] -> [a]
takeWhile Char -> Bool
isDigit (forall a. (a -> Bool) -> [a] -> [a]
dropWhile Char -> Bool
isDot String
rest)
in String
major forall a. [a] -> [a] -> [a]
++ String
"." forall a. [a] -> [a] -> [a]
++ String
minor
[String]
_ -> String
""