Question: Please help in writing this program in Haskell, provide step by step instructions with explanations and provide example inputs and outputs so I can understand

Please help in writing this program in Haskell, provide step by step instructions with explanations and provide example inputs and outputs so I can understand the concept.
Description
In this project you will create a prefix-notation expression calculator. The calculator will prompt the user for an expression in prefix notation and calculate the result of the inputted expression.
A history will be kept so that previous results can be used in expressions. You are expected to handle possible errors in the users input.
Details
When ran, the program should immediately prompt the user for an expression. It will evaluate that expression, printing an error message if an error is encountered. A simple generic message Invalid Expression is alright. There should be a history represented as a simple list of values. Every time the program succeeds in evaluating the expression, the result will be added to the history and printed to the screen. Remember, you are programming in a functional language. The history should be a parameter to your eval loop function. So, adding a value to history should involve cons-ing it with the existing history. When the value is printed to screen, you should include its history id (or index). The id will always be the order it was added to history. So, the first value will be id 1, the second id 2, and so on. The (!?) operator can map a list to its value at a particular index. Using the cons operator to construct the history will result the values being in reverse order of their id. That is, the most recent value will be first in the list. This can be remedied by reversing the list before giving it to (!?).
Expressions
An expression is a value, binary operation, or a unary operation. A value should be represented by a Double.
+ A binary operator that adds together the result of two expressions.
* A binary operator that multiplies together the result of two expressions.
/ A binary operator that divides the result of the first expression by the result of the second.
Dont forget that the user might try to divide by zero. This is an error.
- A unary operator that negates the value of an expression. There is no subtraction. So, to subtract we can add to a negative number.
$n n should be an integer. A value specifying to use the history value corresponding to id n.
a real number a value, can be an integer or non-integer. So,5 and 5.0 are both valid and are the same value.
Expressions are in prefix notation and read from left to right. So, if I wanted to evaluate 2 $1+ $2, I would write +*2$1$2. Whitespace can be used to divide tokens (like to numbers), but otherwise insignificant. In the previous example I could also write +*2\$1\$2. It is an error, if the expression is evaluated, but there is still text remaining. For instance, +122 is an error. The expression is 1+2. The second 2 is not part of the expression.
Some Tips
Dont try to do everything in one function.
Create functions that evaluates a particular type of expression and yields a two element list. The first element would be the result of the evaluation, and the second the remaining characters in the expression.
Some useful functions
fromIntegral (can convert an integer to another number type)
isDigit (Requires you to import Data.Char)
isSpace (Requires you to import Data.Char)
toLower (Requires you to import Data.Char)
getLine
print
putStr/putStrLn
read
span
map
In addition, you may want to import Data.Maybe to gain the Maybe type for error handling.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!