How to make nested match expressions more pleasent?

In your examples, monadic style will work well.

But in general, you can put the happy case as the last one and deindent it. This is similar to the “early return” idiom in imperative languages.

2 Likes