annotate keep-indexed, and add type annotation to
a util function