title: How to use cats and State Monad
body: <p>I've used <a href="http://typelevel.org/cats/" rel="noreferrer">cats</a> for the first time to solve <a href="http://adventofcode.com/2016/day/1" rel="noreferrer">day 1</a> of advent of code and I'm wondering if it's possible to improve things.</p>
  
  <p>Given a method <code>update</code> with the following signature
  <code>def update(i: Instruction): PosAndDir =&gt; PosAndDir</code></p>
  
  <p>I've come up with :</p>
  
  <pre><code>val state: State[PosAndDir, List[Unit]] = instructions.map(i =&gt; State.modify(update(i))).toList.sequenceU
  val finalState = state.runS(PosAndDir(Pos(0, 0), North)).value
  </code></pre>
  
  <p>And also</p>
  
  <pre><code>  def update2(i: Instruction): State[PosAndDir, Option[Pos]] =
      State.modify(update(i)).inspect(pad =&gt; if (i == Walk) Some(pad.pos) else None)
    …
    val state = instructions.map(update2).toList.sequenceU
    val positions = state.runA(PosAndDir(Pos(0, 0), North)).value.flatten
  </code></pre>
  
  <p>More precisely, questions are :</p>
  
  <ol>
  <li>why do we need to call <code>.value</code> (with scalaz, it's transparent) ?</li>
  <li>is there a way to write <code>update2</code> with a for comprehension to improve readability ?</li>
  <li>is there an <code>Applicative</code> instance for <code>Seq</code> in cats (I know there is not in scalaz). ?</li>
  <li>any idea to improve the code ?</li>
  </ol>