now I get what a monad is

Ok, I admit it, after struggling through monads, I know understand them at a basic level and their value.  There are may blogs out there that are really good but I will call out the haskell blog being especially helpful.

There seems to be alot of noise, at least 2-3 years ago, around the IO monad in particular. According to the haskell blog, the IO monad helps mark computations that perform IO. Since haskell is a pure functional language, which means no side effects in functions, the IO monad helps delimit the scope of where impure operations are performed. In this use, it is like a marker.

However, in scala, which is an impure functional language, functions can have side effects. So is there value in the IO monad? Maybe, but it may be awhile before I see where that value is. Since I can contain side effects and mark them using types e.g. a DAO object for database access, I'm okay for the moment not using the IO monad but I can see where the general concept may be useful for non-IO computations as well.

I only reached my current level of understanding by playing around with some trying out some small coding examples that I encounter in my work but applying monads to the implementation.

There are options to using monads, but it turns out they can be convenient and with scala's syntatic support using for-comprehensions, the code does turn out to be clearer to read. Of course, there is a trade-off, but monads appear to be a pattern that I can now think about in my bag of tricks that I use when solving problems. I'll need more practice in using and applying them of course and I am sure that my next level of understanding and ability to exploit them will come after using them for awhile.

Popular posts from this blog

graphql (facebook), falcor (netflix) and odata and ...

React, Redux, Recompose and some simple steps to remove "some" boilerplate and improve reuse

Using wye and tee with scalaz-stream