Denis Baltor
1 min readMar 18, 2023

--

Thanks for your article. Although I can see where you wanted to go, I think you stopped short and ended up with a terrible imperative code that looks Go (as already commented) instead of FP. In your example, you'd be better off using Exceptions.

The article you refer to actually gives the whole recipe which I think you missed in your article:

"What we do here is checking the Result of each method invocation to see if there is an error. If not, we continue with the next step. [...] This is fine, but we have seen this pattern before haven’t we? It is pretty similar to the Optional monad examples in the previous post. So how about we try to convert the Result type into a Monad. Remember, we need unit, flatMap and a bunch of rules."

If I may, I'd suggest you include flatMap in your implementation and show the result in a monadic composition.

--

--

Denis Baltor
Denis Baltor

Written by Denis Baltor

I'm passionate about software engineering and everything Cloud Native. I love designing and coding as both are the two sides of the same coin.

No responses yet