import "IO" import "Interact" execE :: Int -> String -> IO () execE state s | state == 0 = do execW "test" loopE 2 | state == 1 = do putStr "OK" loopE 0 | state == 2 = do putStr "bye" loopE :: Int -> IO () loopE state = do putStr "> " s <- getLine execE state s -- writes a file execW :: String -> IO () execW s = stringToFile s "blabla" -- save a string to a file of which the name is indicated -- by the second string stringToFile :: String -> String -> IO () stringToFile s fileName = do toHandle <- openFile fileName ReadWriteMode hPutStr toHandle s hClose toHandle putStr "Done."