From e7dbb4348d17f44c0f9162bea68738f3e2dc72f8 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 26 Jan 2017 21:11:21 +1100 Subject: Moving some code to Miscellaneous --- src/main.hs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/main.hs') diff --git a/src/main.hs b/src/main.hs index 8cec703..4059d3b 100644 --- a/src/main.hs +++ b/src/main.hs @@ -10,6 +10,7 @@ import qualified Data.Maybe as Maybe import qualified Counter as Sen import qualified Candidate as Cand import qualified Election as Elt +import qualified Miscellaneous as Misc @@ -41,18 +42,9 @@ defaultOptions = Options -readMaybe :: Read a => String -> Maybe a -readMaybe s = - case reads s of - [(val, "")] -> Just val - _ -> Nothing - - - - electOpt :: String -> (Options -> Options) electOpt str = - let r = readMaybe str :: Maybe Int + let r = Misc.readMaybe str :: Maybe Int jr = if (Maybe.isJust r && Maybe.fromJust r > 0) then r else Nothing in (\opts -> opts { getNumToElect = jr }) @@ -73,6 +65,10 @@ optionHeader = "Note that the -c, -p, -o, -e, -s options are all\n" ++ "required for normal operation.\n" +furtherHelp = + "Please be sure to provide all required options to run the election counter.\n" ++ + "For further information consult '--help'.\n" + optionData :: [Opt.OptDescr (Options -> Options)] optionData = [ Opt.Option ['v'] ["verbose"] @@ -119,14 +115,6 @@ getOpts argv = -furtherHelp :: String -furtherHelp = - "Please be sure to provide all required options to run the election counter.\n" ++ - "For further information consult '--help'.\n" - - - - main = do rawArgs <- Env.getArgs (options, arguments) <- getOpts rawArgs -- cgit