title: Understanding why Zipper is a Comonad
body: <p>This is a follow-up to the <a href="https://stackoverflow.com/a/23984628/521070">answer</a> to my previous question.</p>
  
  <p>Suppose I need to map each item <code>a:A</code> of <code>List[A]</code> to <code>b:B</code> with function <code>def f(a:A, leftNeighbors:List[A]): B</code> and generate <code>List[B]</code>.</p>
  
  <p>Obviously I cannot just call <code>map</code> on the list but I can use the list <em>zipper</em>. The zipper is a cursor to move around a list. It provides access to the current element (<code>focus</code>) and its neighbors. </p>
  
  <p>Now I can replace my <code>f</code> with  <code>def f'(z:Zipper[A]):B = f(z.focus, z.left)</code> and pass this new function <code>f'</code> to <code>cobind</code> method of <code>Zipper[A]</code>. </p>
  
  <p>The <code>cobind</code> works like this: it calls that <code>f'</code> with the zipper, then moves the zipper, calls<code>f'</code> with the <em>new</em> "moved" zipper, moves the zipper again and so on, and so on ... until the zipper reaches the end of the list.  </p>
  
  <p>Finally, the <code>cobind</code> returns a new zipper of type <code>Zipper[B]</code>, which can be transformed to the list and so the problem is solved.</p>
  
  <p>Now note the symmetry between <code>cobind[A](f:Zipper[A] =&gt; B):Zipper[B]</code> and <code>bind[A](f:A =&gt; List[B]):List[B]</code> That's why <code>List</code> is a <code>Monad</code> and <code>Zipper</code> is a <code>Comonad</code>.</p>
  
  <p>Does it make sense ?</p>