(Full code in TypeScript playground: link.)
I have a Result type for computations that either succeed with a value of type T or fail
Result
T