title: How to pattern match on an empty nested list in Haskell?
body: <p>I am trying to implement a simple function that would "rotate" a matrix as a learning exercise but cannot pass the point where I have to deal with an empty nested list in the pattern matching case.</p>
  
  <pre><code>rotate :: [[Int]] -&gt; [[Int]] -&gt; [[Int]]
  rotate m acc =
    case m of
      [] -&gt; []
      [[]:_] -&gt; acc
      m -&gt; rotate (map tail m) (acc ++ [(map head m)])
  </code></pre>
  
  <p>Input: [[8, 9, 4], [7, 6, 5]]</p>
  
  <p>Output: [[4,5], [9,6], [8,7]]</p>
  
  <pre><code>Main.hs:10:6: error:
      • Couldn't match expected type ‘Int’ with actual type ‘[a0]’
      • In the pattern: []
        In the pattern: [] : _
        In the pattern: [[] : _]    | 10 |     [[]:_] -&gt; acc    |      ^^ Failed, no modules loaded.
  </code></pre>