summaryrefslogtreecommitdiff
path: root/src/main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.hs')
-rw-r--r--src/main.hs24
1 files changed, 6 insertions, 18 deletions
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