main :: IO ()
main = do
contents <- readFile "text.txt"
let database = (read contents :: [Film])
putStr "Please enter your username: "
userName <- getLine
menu database
where menu newDb = do putStrLn "\nPlease select an option:"
putStrLn "1: Display all films currently in the database"
putStrLn "2: Add a new film to the database"
putStrLn "3: Search for films by director"
putStrLn "5: Exit"
putStr "\nSelected option: "
option <- getLine
case option of
"1" -> putStrLn(formatDatabase newDb)
"2" -> do putStr "Name of film: "
title <- getLine
putStr "Name of director: "
director <- getLine
putStr "Year of release: "
year <- getLine
putStrLn(formatDatabase $ addFilm title director (read year) [] newDb)
"3" -> do putStr "Name of director: "
director <- getLine
putStrLn $ formattedByDirector director
menu newDb
返回错误:
Parse error in pattern: putStr
On the line: "2" -> do putStr "Name of film: "