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