decode.hs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import Control.Monad
import Data.Set(Set, fromList)
import Caesar

getDict :: FilePath -> IO (Set String)
getDict path = do contents <- readFile path
                  return (fromList (words contents))

getSecrets :: FilePath -> IO [String]
getSecrets path = do contents <- readFile path
                     return (lines contents)

main = do 
    dict <- getDict "word_list.txt"
    secrets <- getSecrets "secret.txt"
    let answers =  map (decode dict) secrets
    forM_ answers putStrLn