[commit: ghc] wip/nfs-locking: Add instance ShowAction PackageData. (7792b9a)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:02:34 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/7792b9a32bbc24e3d3a0fb04f534e7c293ac9ea2/ghc
>---------------------------------------------------------------
commit 7792b9a32bbc24e3d3a0fb04f534e7c293ac9ea2
Author: Andrey Mokhov <andrey.mokhov at ncl.ac.uk>
Date: Wed Jan 7 16:30:30 2015 +0000
Add instance ShowAction PackageData.
>---------------------------------------------------------------
7792b9a32bbc24e3d3a0fb04f534e7c293ac9ea2
src/Oracles/PackageData.hs | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/Oracles/PackageData.hs b/src/Oracles/PackageData.hs
index 831fec9..2af8e21 100644
--- a/src/Oracles/PackageData.hs
+++ b/src/Oracles/PackageData.hs
@@ -2,7 +2,7 @@
module Oracles.PackageData (
PackageDataPair (..),
- packagaDataOption, PackageDataKey (..)
+ PackageData (..)
) where
import Development.Shake.Classes
@@ -12,26 +12,27 @@ import Util
newtype PackageDataPair = PackageDataPair (FilePath, String)
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
-packagaDataOptionWithDefault :: FilePath -> String -> Action String -> Action String
-packagaDataOptionWithDefault file key defaultAction = do
+packagaDataWithDefault :: FilePath -> String -> Action String -> Action String
+packagaDataWithDefault file key defaultAction = do
maybeValue <- askOracle $ PackageDataPair (file, key)
case maybeValue of
Just value -> return value
Nothing -> defaultAction
-data PackageDataKey = Modules | SrcDirs | PackageKey | IncludeDirs | Deps | DepKeys
- deriving Show
+data PackageData = Modules FilePath | SrcDirs FilePath | PackageKey FilePath
+ | IncludeDirs FilePath | Deps FilePath | DepKeys FilePath
+ deriving Show
-packagaDataOption :: FilePath -> PackageDataKey -> Action String
-packagaDataOption file key = do
- let (keyName, ifEmpty) = case key of
- Modules -> ("MODULES" , "" )
- SrcDirs -> ("HS_SRC_DIRS" , ".")
- PackageKey -> ("PACKAGE_KEY" , "" )
- IncludeDirs -> ("INCLUDE_DIRS", ".")
- Deps -> ("DEPS" , "" )
- DepKeys -> ("DEP_KEYS" , "" )
- keyFullName = replaceSeparators '_' $ takeDirectory file ++ "_" ++ keyName
- res <- packagaDataOptionWithDefault file keyFullName $
- error $ "\nCannot find key '" ++ keyName ++ "' in " ++ file ++ "."
- return $ if res == "" then ifEmpty else res
+instance ShowAction PackageData where
+ showAction key = do
+ let (keyName, file, ifEmpty) = case key of
+ Modules file -> ("MODULES" , file, "" )
+ SrcDirs file -> ("HS_SRC_DIRS" , file, ".")
+ PackageKey file -> ("PACKAGE_KEY" , file, "" )
+ IncludeDirs file -> ("INCLUDE_DIRS", file, ".")
+ Deps file -> ("DEPS" , file, "" )
+ DepKeys file -> ("DEP_KEYS" , file, "" )
+ keyFullName = replaceSeparators '_' $ takeDirectory file ++ "_" ++ keyName
+ res <- packagaDataWithDefault file keyFullName $
+ error $ "\nCannot find key '" ++ keyName ++ "' in " ++ file ++ "."
+ return $ words $ if res == "" then ifEmpty else res
More information about the ghc-commits
mailing list