title: Understanding IO monad in Scala
body: <p>I'm learning scalaz and now I'm trying to understand the point of <code>IO</code> monad. I read <a href="https://underscore.io/blog/posts/2015/04/28/monadic-io-laziness-makes-you-free.html" rel="noreferrer"><strong><em>this article</em></strong></a> about IO monads and trying to run the simplest example myself:</p>
  
  <pre><code>val io = println("test").pure[IO]
  println("before")
  io.unsafePerformIO()
  </code></pre>
  
  <p>Yes, it works as expected. It prints</p>
  
  <pre><code>before
  test
  </code></pre>
  
  <p>But I cannot catch the gist of the IO monad. What is the trick? Except "maintains substitution" as specified in the article I referenced. </p>
  
  <p>The substitution does not seem too useful too me now. Could you please explain?</p>
  
  <p>From what I can think. Imagine I have some traits:</p>
  
  <pre><code>trait Reader{
      def read(): List[Int]
  }
  
  trait Writer[T]{
      def write(t: T): Unit
  }
  </code></pre>
  
  <p>So I have a reader which can read monadic values (<code>List</code> in my case). And then I need to write all values from the container somewhere else, performing some transfomation on them. Can IO monad be useful in that case?</p>