title: Create CArray of CArray
body: <p>I want to create a CArray of CArray:</p>
  
  <pre><code>{-# LANGUAGE ScopedTypeVariables #-}
  {-# LANGUAGE FlexibleContexts #-}
  
  module Main where
  
  import Data.Array.CArray
  import Data.Array.Base
  
  testArr :: CArray Int Double
  testArr =  listArray (0,5) [0..5]
  
  -- divvyArray :: Int -&gt; CArray Int Double -&gt; CArray Int (CArray Int Double)
  divArray w arr = arr'
    where (m1,m2) = bounds arr
          len = m2 - w + 2
          divInd = zip [0..(m2-w+1)] [w..m2]
          f ix = slice (0,w) ix arr 
          arr' = listArray (0,len) [ f k | k &lt;- divInd] 
  </code></pre>
  
  <p>The code compiles and has type <code>divArray :: (Enum p, Shapable p, IArray a1 e, IArray a2 (a1 p e), Ix p, Num p) =&gt; p -&gt; a1 p e -&gt; a2 p (a1 p e)'</code></p>
  
  <p>But when I run it</p>
  
  <blockquote>
    <p>divArray 3 testArray</p>
  </blockquote>
  
  <p>It gives this error:</p>
  
  <pre><code>&lt;interactive&gt;:168:1: error:
      • Non type-variable argument
          in the constraint: IArray a2 (CArray Int Double)
        (Use FlexibleContexts to permit this)
      • When checking the inferred type
          it :: forall (a2 :: * -&gt; * -&gt; *).
                IArray a2 (CArray Int Double) =&gt;
                a2 Int (CArray Int Double)
  </code></pre>
  
  <p>Just to give an idea, in <code>[]</code>, the result should be:</p>
  
  <blockquote>
    <p>divList 3 [0..5]</p>
  </blockquote>
  
  <pre><code>[[0..2],[1..3],[2..4],[3..5]]
  </code></pre>