import "IO" import "Interact" -- this reads a line in a loop and then executes exec loopE :: Int -> Interact loopE state = readLine "> " (execE state) execW s = stringToFile s "blabla" -- this function interprets the input string execE :: Int -> String -> Interact execE state s | state == 1 = writeStr "OK" (loopE 0) | state == 0 = execW "test" (loopE 2) | state == 2 = writeStr "bye" end -- save a string to a file of which the name is indicated -- by the second string stringToFile s fileName = do toHandle <- openFile fileName WriteMode hPutStr toHandle s hClose toHandle putStr "Done."