Reputation: 89
Is it possible using's Haskell's input and output to be able to capture and store user entered data into variables?
For example if user was asked a question:
Enter your firstname: Ben, then firstname = Ben, Enter your surname: Davies, then surname = Davies
And finally a print statement to concatenate the 2 variables ie. firstname ++ surname = Ben Davies?
Thanks in advance for the help!
Upvotes: 0
Views: 286
Reputation: 3766
Yes, it is possible.
main = do
putStrLn "Enter your first name"
firstName <- getLine
putStrLn "Enter your last name"
lastName <- getLine
putStrLn $ "Your full name is " ++ firstName ++ " " ++ lastName
Upvotes: 4