safeGetEnv :: String -> IO (Maybe String)
safeGetEnv var = handle mcatch $ menv var
   where mcatch :: IOError -> IO (Maybe String)
         mcatch _ = return Nothing
         menv :: String -> IO (Maybe String)
         menv var = do val <- getEnv var
                       return $ Just val
safeGetEnv :: String -> IO (Maybe String)
safeGetEnv var = handle mcatch $ menv var
   where mcatch :: IOError -> IO (Maybe String)
         mcatch _ = return Nothing
         menv :: String -> IO (Maybe String)
         menv var = do val <- getEnv var
                       return $ Just val
safeGetEnv var = handle mcatch $ menv var
   where mcatch :: IOError -> IO (Maybe String)
         mcatch _ = return Nothing
         menv :: String -> IO (Maybe String)
         menv var = do val <- getEnv var
                       return $ Just val