[commit: ghc] wip/nfs-locking: Replace option with instance ShowAction Option. (1495a2d)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:18:10 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/1495a2d66f0a9cb8082285b68c1e42cf954eb6b8/ghc

>---------------------------------------------------------------

commit 1495a2d66f0a9cb8082285b68c1e42cf954eb6b8
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Fri Jan 2 02:43:40 2015 +0000

    Replace option with instance ShowAction Option.


>---------------------------------------------------------------

1495a2d66f0a9cb8082285b68c1e42cf954eb6b8
 src/Oracles/Option.hs | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/src/Oracles/Option.hs b/src/Oracles/Option.hs
index 3661b71..899aec7 100644
--- a/src/Oracles/Option.hs
+++ b/src/Oracles/Option.hs
@@ -1,6 +1,5 @@
 module Oracles.Option (
     Option (..),
-    option, argOption,
     ghcWithInterpreter, platformSupportsSharedLibs, windowsHost
     ) where
 
@@ -13,31 +12,26 @@ data Option = TargetOS | TargetArch | TargetPlatformFull
             | SrcHcOpts
             | HostOsCpp
 
-option :: Option -> Action String
-option opt = askConfig $ case opt of 
-    TargetOS                -> "target-os"
-    TargetArch              -> "target-arch"
-    TargetPlatformFull      -> "target-platform-full"
-    ConfCcArgs        stage -> "conf-cc-args-stage-"         ++ (show . fromEnum) stage
-    ConfCppArgs       stage -> "conf-cpp-args-stage-"        ++ (show . fromEnum) stage
-    ConfGccLinkerArgs stage -> "conf-gcc-linker-args-stage-" ++ (show . fromEnum) stage
-    ConfLdLinkerArgs  stage -> "conf-ld-linker-args-stage-"  ++ (show . fromEnum) stage
-    IconvIncludeDirs        -> "iconv-include-dirs"
-    IconvLibDirs            -> "iconv-lib-dirs"
-    GmpIncludeDirs          -> "gmp-include-dirs"
-    GmpLibDirs              -> "gmp-lib-dirs"
-    SrcHcOpts               -> "src-hc-opts"
-    HostOsCpp               -> "host-os-cpp"
-
-argOption :: Option -> Args
-argOption opt = do
-    opt' <- option opt
-    arg [opt']
+instance ShowAction Option where
+    showAction opt = askConfig $ case opt of 
+        TargetOS                -> "target-os"
+        TargetArch              -> "target-arch"
+        TargetPlatformFull      -> "target-platform-full"
+        ConfCcArgs        stage -> "conf-cc-args-stage-"         ++ (show . fromEnum) stage
+        ConfCppArgs       stage -> "conf-cpp-args-stage-"        ++ (show . fromEnum) stage
+        ConfGccLinkerArgs stage -> "conf-gcc-linker-args-stage-" ++ (show . fromEnum) stage
+        ConfLdLinkerArgs  stage -> "conf-ld-linker-args-stage-"  ++ (show . fromEnum) stage
+        IconvIncludeDirs        -> "iconv-include-dirs"
+        IconvLibDirs            -> "iconv-lib-dirs"
+        GmpIncludeDirs          -> "gmp-include-dirs"
+        GmpLibDirs              -> "gmp-lib-dirs"
+        SrcHcOpts               -> "src-hc-opts"
+        HostOsCpp               -> "host-os-cpp"
 
 ghcWithInterpreter :: Condition
 ghcWithInterpreter = do
-    os   <- option TargetOS
-    arch <- option TargetArch
+    os   <- showAction TargetOS
+    arch <- showAction TargetArch
     return $
         os `elem` ["mingw32", "cygwin32", "linux", "solaris2", "freebsd", "dragonfly", "netbsd", "openbsd", "darwin", "kfreebsdgnu"]
         &&
@@ -45,10 +39,10 @@ ghcWithInterpreter = do
 
 platformSupportsSharedLibs :: Condition
 platformSupportsSharedLibs = do
-    platform <- option TargetPlatformFull
+    platform <- showAction TargetPlatformFull
     return $ platform `notElem` [ "powerpc-unknown-linux", "x86_64-unknown-mingw32", "i386-unknown-mingw32" ] -- TODO: i386-unknown-solaris2?
 
 windowsHost :: Condition
 windowsHost = do
-    hostOsCpp <- option HostOsCpp
+    hostOsCpp <- showAction HostOsCpp
     return $ hostOsCpp `elem` ["mingw32", "cygwin32"]



More information about the ghc-commits mailing list