Python\'s enumerate on lists can be written as zip [0..]. I looked at Control.Lens.Traversal and Control.Lens.Indexed, but I couldn\'t figure out how to use len
One solution would be to use the State monad with traverse, since it is also Applicative:
enumerate :: (Integral n, Traversable t) => t a -> t (n, a)
enumerate t = evalState (traverse go t) 0
where
go a = do
i <- get
modify (+1)
return (i, a)