Functional extensions for result
Introduction In an earlier post, I created Result<TValue, TError>, a generic, allocation-free struct. On its own, it supports only procedural programming. Call something, check Success or Failure, branch and repeat. This is the same boilerplate as Go’s if err != nil. In functional languages, a result is a value like any other, so operations can be composed on it directly. F# includes a Result module for this. This post discusses extension methods that reimplement map, mapError, bind, iter, iterError, defaultValue and defaultWith for Result<TValue, TError>. They let you chain steps without checking Success or Failure after each call. ...