From 3cba01ec074fc90960c5ba2baee9cab987b3b567 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 4 Apr 2021 17:41:15 +0100 Subject: [PATCH] Create First Program --- FirstProgram/CreateEmail.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 FirstProgram/CreateEmail.hs diff --git a/FirstProgram/CreateEmail.hs b/FirstProgram/CreateEmail.hs new file mode 100644 index 0000000..0458186 --- /dev/null +++ b/FirstProgram/CreateEmail.hs @@ -0,0 +1,23 @@ +toPart :: [Char] -> [Char] +toPart recipient = "Dear " ++ recipient ++ ",\n" + +bodyPart :: [Char] -> [Char] +bodyPart bookTitle = "Thanks for Purchasing" ++ bookTitle ++ ".\n" + +fromPart :: [Char] -> [Char] +fromPart author = "Thanks, \n" ++ author + +createEmail :: [Char] -> [Char] -> [Char] -> [Char] +createEmail recipient bookTitle author = toPart recipient ++ + bodyPart bookTitle ++ + fromPart author + +main :: IO () +main = do + print "Who is the email for?" + recipient <- getLine + print "What is the Title?" + title <- getLine + print "Who is the Author?" + author <- getLine + print (createEmail recipient title author) \ No newline at end of file