(!!) operator with overflowing integer
haskell
Solution
Data.List.genericIndex supports using any Integral number to index, so you can use Integer if you want.
Problem
I have just recently started learning Haskell and started playing around with the idea of infinite lists and lazy evaluation. I constructed an infinite list and tried to access an element at a very, very distant index using the `!!` operator. The issue is that the type signature for the `!!` operator is the following: `(!!) :: [a] -> Int -> a` Which means it takes an `Int` as an index to retrieve that element from the list. Now, my problem occurs whenever I try to index something so distant that it overflow the `Int` and therefore goes negative. What would then be the proper Haskell way of doing this?