You should construct a Haskell function
spellcheck :: String -> [String] -> IO ()so that given an input text string text and a list of words in a dictionary dictionary, the expression spellcheck text dictionary shows successive lines of text with 2 additional spaces added to the left margin. Each line of text that contains a word not in dictionary is flagged by placing a "*" in the left margin, and by a string of "X" characters placed underneath the word in error.
Here is an example. Suppose that text contains the following string
"The first line,\nand the second lyne.\nThe end."and the dictionary d contains the list of strings
["and", "end", "first", "line", "or", "the"]Then spellcheck text dictionary should display the following:
The first line, * and the second lyne. XXXXXX XXXX The end.
A word is composed entirely of consecutive alphabetic characters and is terminated by a non-alphabetic character (for example, a space, a newline or a period) or by the end of the string in which it appears. Words in a dictionary contain only lower-case characters, and capitalization should be ignored in determining whether a word appears in the dictionary.
The string of "X" characters marking the word in error should appear directly below the letters making up the word, but should not extend to include punctuation or any spaces. The output lines should reflect the input lines in text exactly, including spacing.
In grading this assignment we will place additional weight on the clarity and simplicity of your program.