Fix dictionary reading
This commit is contained in:
parent
04d4119b7a
commit
5880d11869
14
main.hs
14
main.hs
@ -1,7 +1,9 @@
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
|
||||
import System.IO
|
||||
import Control.Monad (when)
|
||||
import System.Console.ArgParser
|
||||
import Control.Monad
|
||||
import Control.Applicative
|
||||
|
||||
import Paths_alea (getDataFileName)
|
||||
import Alea.Diceware
|
||||
@ -28,8 +30,16 @@ interface =
|
||||
(mkApp =<< parser)
|
||||
|
||||
main :: IO ()
|
||||
main = getProgArgs >>= defaults >>= exec
|
||||
main = interface >>= flip runApp (readDict >=> exec)
|
||||
|
||||
-- Default path of the dictionary
|
||||
path :: IO FilePath
|
||||
path = getDataFileName "dict/diceware"
|
||||
|
||||
-- Read dictionary file
|
||||
readDict :: ProgArgs -> IO ProgArgs
|
||||
readDict args@ProgArgs{..} =
|
||||
readFile dictionary >>= \x -> return args {dictionary = x}
|
||||
|
||||
-- Main function
|
||||
exec :: ProgArgs -> IO ()
|
||||
|
Loading…
Reference in New Issue
Block a user