by codewright · 13y ago · 0 comments
Hey. Hey. heyyyyy.
I've used bind + maybe monad 'ish stuff in Python to clean up code previously littered with redundant if checks.
You can also look at it as a degenerate case of Either. (That is, Maybe a ~ Either () a.)
This is "degenerate" in the mathematical sense, much the same way you can think of a point as a degenerate circle.
I'd observe in my code that I rarely have an enormous do block using Maybe; instead what I see a lot is use of the monadic interface to tie things together that would normally be a lot of if blocks, all on one line into one expression. You start missing that in other languages real fast. Also the Applicative instance is often quite useful, allowing you to easily tie together several things that return Maybes into a call of some sort that does the right thing if one of them is a Nothing, almost "free" from a syntax point of view.