module Main where
import           Data.Char     (toLower)
import           Data.Set      (Set, fromList, member)
import           GameState
import           System.IO     (IOMode (ReadMode), hGetContents, openFile)
import           System.Random (getStdGen, randomR)


getWordsLst :: IO [String]
getWordsLst = do
  handle <- openFile "words" ReadMode
  contents <-  hGetContents handle
  return $ words contents


getRandomWord :: [String] -> IO String
getRandomWord words = do
  gen <- getStdGen
  let (i, _) = randomR (0, (length words) - 1) gen in
   return $ words !! i


main = do
  words <- getWordsLst
  word <- getRandomWord words
  -- putStrLn $ "word is: " ++ word
  makeGameStep (GameState (map toLower word) $ fromList "")
