diff --git a/main.hs b/main.hs index 071fa67..b6e85c1 100644 --- a/main.hs +++ b/main.hs @@ -9,7 +9,7 @@ import Alea.Diceware import Alea.Random _NAME = "Alea" -_VERSION = "0.2.0" +_VERSION = "0.2.1" _INFO = _NAME ++ " version " ++ _VERSION _ABOUT = "a diceware passphrase generator" _COPYRIGHT = "(C) Michele Guerini Rocco 2014" @@ -44,12 +44,11 @@ main = getProgArgs >>= defaults >>= exec -- Assign default values to unspecified args defaults :: Args -> IO Args defaults args@Args{..} = do - defaultDict <- getDataFileName "dict/diceware" >>= readFile - dict <- readFile dictionary - return args - { dictionary = if null dict then defaultDict else dict - , phraseLength = if phraseLength == 0 then 6 else phraseLength - } + dictionary' <- if null dictionary + then getDataFileName "dict/diceware" >>= readFile + else readFile dictionary + let phraseLength' = if phraseLength == 0 then 6 else phraseLength + return args { dictionary = dictionary', phraseLength = phraseLength'} -- Main function exec :: Args -> IO ()