After read­ing this old post by Don Syme, I really liked the idea of wrap­ping the result of any com­pu­ta­tion into an option type to sig­nify suc­cess and fail­ure cases and stop sub­se­quent com­pu­ta­tions on the first fail­ure. It’s neat but I wanted to tweak a cou­ple of things to make it more useful:

  • excep­tional cases are not han­dled right now
  • being able to retry on excep­tions will be very useful
  • being able to dic­tate how many retries are made will be use­ful too

with those three points in mind, here’s the code I ended up with:

image

And some quick tests:

image

Let me know what you think and if there’s any­thing else I can tweak to make this more useful!

Share