title: Defining an operator to access a multi-dimensional array
body: <p>I got the idea of defining an operator that takes a (possibly) multidimensional list, and a list of indices, and returns the element. My proto attempt was:</p>
  
  <pre><code>(!!!) xs [i]            = xs !! i
  (!!!) xs (cI : restI)   = (xs !! cI) !!! restI
  </code></pre>
  
  <p>In retrospect, this obviously has a lot of problems. I couldn't figure out a type signature first off, then I realized that in line 2, the return type of (xs !! cI) will constantly change, and may not always even be a list (on the last "iteration")</p>
  
  <p>I realized that to access a multi-dimensional array using the standard subscript operator, you can simply chain it like:</p>
  
  <pre><code>[[1,2,3],[4,5,6],[7,8,9]] !! 1 !! 1 = 5
  </code></pre>
  
  <p>And realized that that looks a lot like a fold, so I tried:</p>
  
  <pre><code>(!!!) xxs inds = foldl (!!) xxs inds
  or simply (!!!) = foldl (!!) 
  </code></pre>
  
  <p>But I get the same error as my first attempt; that I'm trying to construct an infinite type.</p>
  
  <p>Is this type of function even possible (through a hack or otherwise)? I'm starting to think that its type is just too up in the air to work.</p>
  
  <p>Just as an example, I was aiming for the following:</p>
  
  <pre><code>[[1,2,3],[4,5,6],[7,8,9]] !!! [1,1] = 5
  </code></pre>