You should already know what an EvalExpr is.So implement a functional one, that is able to parse a string given as argument and display the resultingvalue, followed by a new line.
∼/B-FUN-500> ./funEvalExpr “3 + 5.34”
8.34
∼/B-FUN-500> ./funEvalExpr “(0.345+ 5 )*( -2-1) / 3"
-5.35
The output must always have two digits after the decimal points.For instance1.00,3.14,4.50,0.67.
Your program must handlefloat numbers,parenthesesand the following binary operators:
1. sum (+) and difference (-)
2. product (*) and division (\)
3. power (^)
The list above is sorted by precedence, from lower to higher.
You may implement a Packrat parser, following a Parsing Expression Grammar (PEG).
Stack is a convenient build tool/package manager for Haskell.
Its use is required for this project, with version 2.1.3 at least.
It wraps a build tool, either Cabal or hpack.
You are required to use the hpack variant (package.yaml file in your project, autogenerated .cabal file).
This is what stack generates by default with stack new.
Stack is based on a package repository, stackage, that provides consistent snapshots of packages.
The version you use must be in the LTS 14series (resolver: ’lts-14.11’in stack.yaml)
.In stack.yaml, extra-dependencies cannot be used.
base is the only dependency allowed in thelib and executable sections of your project (package.yaml).
There is no restriction on the dependencies of the tests sections.
You must provide a Makefile that builds your stack project (i.e. it should at some pointcall ‘stack build’).‘stack build’ puts your executable in a directory that issystem-dependent, which youmay want to copy
.A useful command to learn this path in a system-independent way is:stack path –local-install-root