From dc2b87315e6e846b87ad28bf577bd5bda8b69141 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Thu, 22 Oct 2026 20:36:25 +0200 Subject: [PATCH] eliminate partial functions --- Config.hs | 4 ++-- Setup.hs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Config.hs b/Config.hs index 073507481..5d8ab358e 100644 --- a/Config.hs +++ b/Config.hs @@ -35,8 +35,8 @@ loadLangs = loadLangsFrom configFile -- | Load language information from specified config file loadLangsFrom:: FilePath -> IO [LangInfo] loadLangsFrom configFile = do - lns <- readFile configFile >>= return . lines - mapM mkLangInfo (tail lns) + _:lns <- readFile configFile >>= return . lines + mapM mkLangInfo lns where maybeBit bits n = if length bits >= (n+1) && length (bits !! n) > 0 then Just (bits !! n) else Nothing boolBit bits n def = if length bits >= (n+1) && length (bits !! n) > 0 then (if def then bits !! n /= "n" else bits !! n == "y") else def diff --git a/Setup.hs b/Setup.hs index d1203b7f3..4870b27d3 100644 --- a/Setup.hs +++ b/Setup.hs @@ -3,7 +3,7 @@ -- | Main build script for RGL import Data.List (find,isPrefixOf,isSuffixOf,(\\)) -import Data.Maybe (catMaybes) +import Data.Maybe (catMaybes,listToMaybe) import System.IO (hPutStrLn,stderr) import System.IO.Error (catchIOError) import System.Exit (ExitCode(..),exitFailure) @@ -119,7 +119,7 @@ mkInfo = do let gf = maybe default_gf id (getFlag gf_flag args) -- Look for install location in a few different places let mflag = getFlag destination_flag args - menvar <- lookupEnv "GF_LIB_PATH" >>= return . fmap (head . splitSearchPath) + menvar <- lookupEnv "GF_LIB_PATH" >>= return . ((=<<) (listToMaybe . splitSearchPath)) mbuilt <- catchIOError (readProcess gf ["--version"] "" >>= return . getPath) (\e -> return Nothing) let inst_dir = @@ -293,7 +293,7 @@ checkArgs args = do getCommands :: [String] -> [RGLCommand] getCommands args = let - cmdModules = head $ filter (\cmd -> cmdName cmd == "modules") rglCommands + cmdModules:_ = filter (\cmd -> cmdName cmd == "modules") rglCommands cmds0 = [ cmd | arg <- args