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:
(!!!) xs [i] = xs !! i
(!!!) xs (cI : restI) = (xs !! cI) !!! restI
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")
I realized that to access a multi-dimensional array using the standard subscript operator, you can simply chain it like:
[[1,2,3],[4,5,6],[7,8,9]] !! 1 !! 1 = 5
And realized that that looks a lot like a fold, so I tried:
(!!!) xxs inds = foldl (!!) xxs inds
or simply (!!!) = foldl (!!)
But I get the same error as my first attempt; that I'm trying to construct an infinite type.
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.
Just as an example, I was aiming for the following:
[[1,2,3],[4,5,6],[7,8,9]] !!! [1,1] = 5