eliminate partial functions

This commit is contained in:
Krasimir Angelov committed 2026-10-22 20:36:25 +02:00
1 parent 7513dca294
commit dc2b87315e
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -35,8 +35,8 @@ loadLangs = loadLangsFrom configFile
-- | Load language information from specified config file -- | Load language information from specified config file
loadLangsFrom:: FilePath -> IO [LangInfo] loadLangsFrom:: FilePath -> IO [LangInfo]
loadLangsFrom configFile = do loadLangsFrom configFile = do
lns <- readFile configFile >>= return . lines _:lns <- readFile configFile >>= return . lines
mapM mkLangInfo (tail lns) mapM mkLangInfo lns
where where
maybeBit bits n = if length bits >= (n+1) && length (bits !! n) > 0 then Just (bits !! n) else Nothing 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 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
+3 -3
View File
@@ -3,7 +3,7 @@
-- | Main build script for RGL -- | Main build script for RGL
import Data.List (find,isPrefixOf,isSuffixOf,(\\)) import Data.List (find,isPrefixOf,isSuffixOf,(\\))
import Data.Maybe (catMaybes) import Data.Maybe (catMaybes,listToMaybe)
import System.IO (hPutStrLn,stderr) import System.IO (hPutStrLn,stderr)
import System.IO.Error (catchIOError) import System.IO.Error (catchIOError)
import System.Exit (ExitCode(..),exitFailure) import System.Exit (ExitCode(..),exitFailure)
@@ -119,7 +119,7 @@ mkInfo = do
let gf = maybe default_gf id (getFlag gf_flag args) let gf = maybe default_gf id (getFlag gf_flag args)
-- Look for install location in a few different places -- Look for install location in a few different places
let mflag = getFlag destination_flag args 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) mbuilt <- catchIOError (readProcess gf ["--version"] "" >>= return . getPath) (\e -> return Nothing)
let let
inst_dir = inst_dir =
@@ -293,7 +293,7 @@ checkArgs args = do
getCommands :: [String] -> [RGLCommand] getCommands :: [String] -> [RGLCommand]
getCommands args = getCommands args =
let let
cmdModules = head $ filter (\cmd -> cmdName cmd == "modules") rglCommands cmdModules:_ = filter (\cmd -> cmdName cmd == "modules") rglCommands
cmds0 = cmds0 =
[ cmd [ cmd
| arg <- args | arg <- args