Result Monad (Discussion)

The language will definitely benefit of a way to return a meaningful, non-critical errors. For now, there are four options:

  • Nil, which doesn’t add any information
  • yield, neither
  • raising an Exception, which adds the question of possible errors a method can return, and have a performance impact.
  • Union of some sort of types (or a monad-like type), which does the job but not very standard.

It would be great to know which “normal”, non-critical errors methods can return, to avoid unhandled exceptions or catching all unconditionally (which is not a very good practice) (related issue: https://github.com/crystal-lang/crystal/issues/7154).
This will make the language safer.