title: Rotate a matrix in Haskell
body: <p>I have this type Mat <code>a = [[a]]</code> to represent a matrix in haskell.
  I have to write a function which rotate a matrix, for e.g <code>[[1,2,3],[0,4,5]</code>,<code>[0,0,6]]</code> will become <code>[[3,5,6],[2,4,0],[1,0,0]]</code> so I made this:</p>
  
  <pre><code>rotateLeft :: Mat a-&gt;Mat a
  rotateLeft [[]] = []
  rotateLeft (h:t) = (map last (h:t)):(rotateLeft (map init (h:t)))
  </code></pre>
  
  <p>but the output is </p>
  
  <pre><code>[[3,5,6],[2,4,0],[1,0,0],[*** Exception: Prelude.last: empty list
  </code></pre>
  
  <p>I don't know what to put in the base case to avoid this exception. 
  Apreciate any help.</p>