From 1e36bd795f2045271d0f413db60de184b20dfc39 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Wed, 4 Oct 2017 16:56:11 +0200 Subject: Move 'trim' to common --- src/CabalHelper/Compiletime/Compile.hs | 3 --- src/CabalHelper/Shared/Common.hs | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CabalHelper/Compiletime/Compile.hs b/src/CabalHelper/Compiletime/Compile.hs index 8cc565e..77cb037 100644 --- a/src/CabalHelper/Compiletime/Compile.hs +++ b/src/CabalHelper/Compiletime/Compile.hs @@ -565,9 +565,6 @@ cabalInstallVersion :: Options -> IO Version cabalInstallVersion Options {..} = do parseVer . trim <$> readProcess cabalProgram ["--numeric-version"] "" -trim :: String -> String -trim = dropWhileEnd isSpace - createPkgDb :: Options -> Either String Version -> IO PackageDbDir createPkgDb opts@Options {..} cabalVer = do db@(PackageDbDir db_path) <- getPrivateCabalPkgDb opts cabalVer diff --git a/src/CabalHelper/Shared/Common.hs b/src/CabalHelper/Shared/Common.hs index 239fe3c..6a12d86 100644 --- a/src/CabalHelper/Shared/Common.hs +++ b/src/CabalHelper/Shared/Common.hs @@ -25,6 +25,7 @@ module CabalHelper.Shared.Common where import Control.Applicative import Control.Exception as E import Control.Monad +import Data.Char import Data.List import Data.Maybe import Data.Version @@ -82,6 +83,9 @@ parsePkgId bs = parseVer :: String -> Version parseVer vers = runReadP parseVersion vers +trim :: String -> String +trim = dropWhileEnd isSpace + majorVer :: Version -> Version majorVer (Version b _) = Version (take 2 b) [] -- cgit v1.2.3