on master help sign in
Cleanup env var lookup
581b884Leif Warner
src/IRTS/CodegenCommon.hs−7
@@ -5,18 +5,11 @@ import IRTS.Simplified
5import IRTS.Defunctionalise
5import IRTS.Defunctionalise
6import IRTS.Lang
6import IRTS.Lang
7
7
8−import Control.Exception
9import Data.Word
8import Data.Word
10−import System.Environment
11
9
12data DbgLevel = NONE | DEBUG | TRACE deriving Eq
10data DbgLevel = NONE | DEBUG | TRACE deriving Eq
13data OutputType = Raw | Object | Executable | MavenProject deriving (Eq, Show)
11data OutputType = Raw | Object | Executable | MavenProject deriving (Eq, Show)
14
12
15−environment :: String -> IO (Maybe String)
16−environment x = Control.Exception.catch (do e <- getEnv x
17− return (Just e))
18− (\y-> do return (y::SomeException); return Nothing)
19−
20-- Everything which might be needed in a code generator - a CG can choose which
13-- Everything which might be needed in a code generator - a CG can choose which
21-- level of Decls to generate code from (simplified, defunctionalised or merely
14-- level of Decls to generate code from (simplified, defunctionalised or merely
22-- lambda lifted) and has access to the list of object files, libraries, etc.
15-- lambda lifted) and has access to the list of object files, libraries, etc.
src/IRTS/System.hs+1−2
@@ -34,8 +34,7 @@ getMvn :: IO String
34getMvn = fromMaybe mvnCommand <$> environment "IDRIS_MVN"
34getMvn = fromMaybe mvnCommand <$> environment "IDRIS_MVN"
35
35
36environment :: String -> IO (Maybe String)
36environment :: String -> IO (Maybe String)
37−environment x = catchIO (Just <$> getEnv x)
37+environment = lookupEnv
38− (\_ -> return Nothing)
39
38
40getTargetDir :: IO String
39getTargetDir :: IO String
41getTargetDir = environment "TARGET" >>= maybe getDataDir return
40getTargetDir = environment "TARGET" >>= maybe getDataDir return