Creating a monadic Result type to unify parsing, type checking, and compilation errors