Conclusion
-
Values of type
IO adescribe programs with side effects, which will eventually result in a value of typea. -
While we cannot safely extract a value of type
afrom anIO a, we can use several combinators and syntactic constructs to combineIOactions and build more-complex programs. -
Do blocks offer a convenient way to run and combine
IOactions sequentially. -
Do blocks are desugared to nested applications of bind operators (
(>>=)). -
Bind operators, and thus do blocks, can be overloaded to achieve custom behavior instead of the default (monadic) bind.
-
Under the hood,
IOactions are stateful computations operating on a symbolic%Worldstate.
What's next
Now, that we had a glimpse at monads and the bind operator, it is time to in the next chapter introduce Monad and some related interfaces for real.