Replace tabs

This commit is contained in:
rnhmjoj 2016-04-28 14:17:43 +02:00
parent 651c65fe65
commit 6c51f66c59
No known key found for this signature in database
GPG Key ID: 362BB82B7E496B7C

View File

@ -9,11 +9,11 @@ import Alea.Diceware
import Alea.Random
data ProgArgs = ProgArgs
{ interactive :: Bool
, dictionary :: FilePath
, phraseLength :: Int
, phrases :: Int
} deriving (Show)
{ interactive :: Bool
, dictionary :: FilePath
, phraseLength :: Int
, phrases :: Int
} deriving (Show)
parser :: IO (ParserSpec ProgArgs)
parser = (\path -> ProgArgs
@ -44,12 +44,12 @@ readDict args@ProgArgs{..} =
-- Main function
exec :: ProgArgs -> IO ()
exec args@ProgArgs{..} =
if interactive
then interact (unlines . map dice . lines)
else do
randWords dictSize phraseLength >>= putStrLn . unwords . map dice'
when (phrases > 1) $ exec args {phrases = phrases - 1}
where
(dict, dictSize) = (parseDiceware dictionary, length dict)
dice n = readDiceware dict (read n :: Int)
dice' n = readDiceware' dict n
if interactive
then interact (unlines . map dice . lines)
else do
randWords dictSize phraseLength >>= putStrLn . unwords . map dice'
when (phrases > 1) $ exec args {phrases = phrases - 1}
where
(dict, dictSize) = (parseDiceware dictionary, length dict)
dice n = readDiceware dict (read n :: Int)
dice' n = readDiceware' dict n