So is this whole IO Monad idea is to simply delay the side effect to the edges? e.g. no pure program is useful, as it will have no input and no output, but if you separate the input and output from computation and delay side effects to the very end using monadic transformations you end up with more "pure" functions and less "side effects" functions? (you can never have zero side effects if you want your code to actually do anything)
This is how I ELI5 this to myself, but not sure if this is the right way to put it. Am I close?
I see it as this - it's simply one of the SOLID principles. (the first one)- Separation of Concerns
The best example (that doesn't involve Monads) that I can think of is this:
def logMessage(foo:String, bar:String) = println(s"your $foo has gone $bar")
def logMessage(foo:String, bar:String) = s"your $foo has gone $bar"
This is obviously not a monad or has anything to do with functional programming, but the second one has no side effects, yet is still useful.In the end the CLIENT of the code can decide what side effects they can do with it (println, log.debug, whatever)
tl;dr - I don't really get all this Monadic stuff, but I see this as simple SOC principle, decouple the data from it's presentation, or in other words, the library should work with pure data, the client should work with the "unpure" input and "unpure output", the library should just transform the input DATA into pure output DATA. the side effects are delayed to the CLIENT instead of the LIBRARY code.
How far am I? Hope it doesn't sound too simplistic (or just plain dumb)