Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using Version.

  • Loading branch information...
commit 76cccce53d1ebbcae31988cfc57105b4a5712c5c 1 parent ed85788
@kazu-yamamoto authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 GenPaths.hs
View
12 GenPaths.hs
@@ -5,14 +5,13 @@ module GenPaths (genPaths) where
import Control.Applicative
import Control.Exception
import Control.Monad
-import Data.List (intercalate, isSuffixOf)
+import Data.List (isSuffixOf)
import Distribution.Package
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse (readPackageDescription)
import Distribution.Verbosity (silent)
import Distribution.Version
import System.Directory
-import System.IO
genPaths :: IO ()
genPaths = do
@@ -24,20 +23,19 @@ genPaths = do
++ "import Data.Version\n"
++ "\n"
++ "version :: Version\n"
- ++ "version = Version [" ++ ver ++ "] []\n"
+ ++ "version = " ++ show ver ++ "\n"
where
check file = do
exist <- doesFileExist file
- unless exist $ hPutStrLn stderr $ file ++ " already exists"
+ when exist . throwIO . userError $ file ++ " already exists"
-getNameVersion :: FilePath -> IO (String,String)
+getNameVersion :: FilePath -> IO (String,Version)
getNameVersion file = do
desc <- readPackageDescription silent file
let pkg = package . packageDescription $ desc
PackageName nm = pkgName pkg
name = map (trans '-' '_') nm
- ver = versionBranch . pkgVersion $ pkg
- version = intercalate "." $ map show ver
+ version = pkgVersion pkg
return (name, version)
where
trans c1 c2 c
Please sign in to comment.
Something went wrong with that request. Please try again.