Equation Parser & AST in F#

functional_programming
Equation Parser & AST in F#

Tech Stack

F#
C#

Description

Built a from-scratch equation parser in F#, converting string math expressions (+, -, *, /, parentheses, with correct operator precedence) into an abstract syntax tree and evaluating the result, as a practical entry point into functional programming.

Used the project to contrast functional and object-oriented paradigms directly: discriminated unions and the Result pattern instead of exceptions, higher-order functions replacing manual loops, pipe operators for readable data flow, and recursion replacing iteration.

  • Implemented a math expression parser and evaluator in F#, building an AST with correct operator precedence.

  • Replaced exception-based error handling with discriminated unions and the Result pattern, matched exhaustively at the call site.

  • Adopted higher-order functions (map/filter) in place of manual for-loops for data transformation.

  • Used pipe operators for readable, left-to-right function composition.

  • Learned idiomatic recursion as a replacement for loop constructs, including recursive tokenizer/parser logic.

  • Substack post