-
-
Save iyefrat/dd1d6f124f298a053dad6824681a7795 to your computer and use it in GitHub Desktop.
a program that given an input, generates a more complex state from it, using both infromation from IO and known variables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NamedFieldPuns #-} | |
module Build where | |
import System.IO | |
import Control.Monad | |
data State = State {word :: String | |
,word1 :: String | |
,word2 :: String | |
,word3 :: String} | |
deriving (Show) | |
state = State "hi" "one hi" "two hi" "bye" | |
main :: IO () | |
main = forever $ do | |
contents <- readFile "state.txt" | |
let one:_ = lines contents | |
let two = "cached two" | |
_ <- putStr "Input a word: " | |
word <- getLine | |
let word1 = unwords [one,word] | |
let word2 = unwords [two,word] | |
print $ state {word,word1,word2} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment