Indexing: encode non-deterministic pattern matching

Also prototype what we'd have with the list monad.
Drop commented out code, add comments

Some comments are taken from the commented out code.
Produce a comprehension & simplify code
Cosmetic cleanups