simple arithmetic expression repl
clone this repo and run cabal run haculator
.
currently, there are two major features in the repl:
- evaluation of arithmetic expressions consisting of only addition, subtraction, multiplication, division, negation, and parentheses;
- solving of linear equations involving one variable.
powered by haskeline, the repl allows for most features you would expect in any rich terminal interface, like scrolling through history.
i have a few plans for the project moving forward:
- add exponentiation and logarithms to the expression grammar
- add the ability to solve multiple linear equations
- make a toy programming language with the calculator as a foundation
this project started as an exercise to see how far i could get parsing arithmetic expressions knowing next to nothing about programming language theory. i wrote a small amount after finishing an MVP and then read the excellent Design patterns for parser combinators (functional pearl) on recommendation. the paper largely inspired the direction of the project from that point forward, and i want to thank the authors for exposing the elegance of parser combinators so thoroughly.