simpleGraph :: (Int -> Int) -> Int -> Int -> StringIf f is a Haskell function of type Int -> Int and a and b are integer values, then simpleGraph f a b should compute a string that, when printed using putStr, shows the value of function f at successive integer inputs between a and b, inclusively. To show the value of f on an input i, a string of stars of length equal to the value of f on input i should be used. For example, given
f :: Int -> Int f i = (i `mod` 3) + 1the string produced by simpleGraph f 0 5 should be
"*\n**\n***\n*\n**\n***\n"which, when printed using putStr (simpleGraph f 0 5), produces
* ** *** * ** ***Notice that the printed result has six lines corresponding to the six inputs 0, 1, 2, 3, 4, 5.
Your program must signal an error if the input interval is empty, i.e. if a > b. Your program should also signal an error if the value of the function to be graphed falls outside the range [0..40] on any input in the interval.
graph :: (Int -> Int) -> Int -> Int -> IO ()that improves on simpleGraph by adding axes and labels to the output graph, and by printing the graph directly instead of requiring the use of putStr. To illustrate, given the function
g :: Int -> Int g i = round (20 + 20 * sin (0.3 * fromInt i))the result of graph g 0 25 should be
0 10 20 30 40 |---------|---------|---------|---------| 0-|******************** |************************** |******************************* |************************************ |*************************************** 5-|**************************************** |*************************************** |************************************* |********************************** |***************************** 10-|*********************** |***************** |*********** |****** |*** 15-| | |* |***** |********* 20-|************** |******************** |************************** |******************************** |************************************ 25-|***************************************The labels on the vertical axis reflect the input interval; only values divisible by 5 should be printed. Signal an error if the input interval falls outside of [-999..999]. The horizontal axis is fixed and is labeled by values from 0 to 40. All labels should be printed right-justified, as shown.