From 47fb59d48232b056c2e7ccfa224ecceb3a89e7c7 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 18 Jan 2019 10:28:36 +0100 Subject: [PATCH] switch to Text.Regex.Applicative.Text so we no longer need to pack and unpack strings manually. --- package.yaml | 2 +- src/Check.hs | 10 +++++----- src/Clean.hs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.yaml b/package.yaml index a20ed35..3ebb257 100644 --- a/package.yaml +++ b/package.yaml @@ -24,7 +24,7 @@ dependencies: - filepath - neat-interpolation >= 0.3 && < 0.4 - optparse-applicative - - regex-applicative + - regex-applicative-text - shelly - text - time >= 1.8 && < 1.10 diff --git a/src/Check.hs b/src/Check.hs index c5cc65e..3a2ff15 100644 --- a/src/Check.hs +++ b/src/Check.hs @@ -14,8 +14,8 @@ import qualified Data.Text as T import Prelude hiding (FilePath) import qualified Shell import Shelly -import qualified Text.Regex.Applicative as RE -import Text.Regex.Applicative (RE, (=~)) +import qualified Text.Regex.Applicative.Text as RE +import Text.Regex.Applicative.Text (RE', (=~)) import Utils (Options(..), UpdateEnv(..), Version) default (T.Text) @@ -27,9 +27,9 @@ data BinaryCheck = BinaryCheck } -- | Construct regex: [^\.]*${version}\.*\s* -versionRegex :: Text -> RE Char () +versionRegex :: Text -> RE' () versionRegex version = - (\_ _ _ _ -> ()) <$> many (RE.psym (/= '.')) <*> RE.string (T.unpack version) <*> + (\_ _ _ _ -> ()) <$> many (RE.psym (/= '.')) <*> RE.string version <*> many (RE.sym '.') <*> many (RE.psym isSpace) @@ -43,7 +43,7 @@ checkBinary argument expectedVersion program = stderr <- lastStderr let hasVersion = isJust $ - (T.unpack . T.unwords . T.lines $ stdout <> "\n" <> stderr) =~ + (T.unwords . T.lines $ stdout <> "\n" <> stderr) =~ versionRegex expectedVersion return $ BinaryCheck program (code == 0) hasVersion) (\_ -> return $ BinaryCheck program False False) diff --git a/src/Clean.hs b/src/Clean.hs index a17111e..693e12f 100644 --- a/src/Clean.hs +++ b/src/Clean.hs @@ -14,16 +14,16 @@ import qualified File import Prelude hiding (FilePath) import qualified Shell import Shelly -import qualified Text.Regex.Applicative as RE -import Text.Regex.Applicative (RE, (=~)) +import qualified Text.Regex.Applicative.Text as RE +import Text.Regex.Applicative.Text (RE', (=~)) import Utils (UpdateEnv(..), Version) default (T.Text) -- | Construct regex: ${version}[^/]+\.(tar|zip) -archiveRegex :: Version -> RE Char () +archiveRegex :: Version -> RE' () archiveRegex version = - (\_ _ _ _ -> ()) <$> RE.string (T.unpack version) <*> some (RE.psym (/= '/')) <*> + (\_ _ _ _ -> ()) <$> RE.string version <*> some (RE.psym (/= '/')) <*> RE.sym '.' <*> (RE.string "tar" <|> RE.string "zip") @@ -80,7 +80,7 @@ fixSrcUrl updateEnv derivationFile attrPath oldSrcUrl = do filter (\url -> newVersion updateEnv `T.isInfixOf` url && - isNothing (T.unpack url =~ archiveRegex (newVersion updateEnv))) & + isNothing (url =~ archiveRegex (newVersion updateEnv))) & map (T.replace "\"" "") forResult <- runExceptT $