How to let a function [a] -> [a] operate on [(a,Int)]?
I find myself often writing code following the pattern: foo xs = map snd $ filter ((< 10).fst) $ zip xs [0..] bar ys = map snd $ sortBy (compare `on` fst) $ zip ys [0..] Now I want to abstract this away foo = indexesOf (filter (<10)) bar = indexesOf sort indexesOf :: ([a] -> [a]) -> [a] -> [Int] indexesOf f xs = map snd $ magick $ zip xs [0..] where magick = undefined How to perform the magick ? Your type signature won't work. You need to be able to give the passed function a list of tuples, which means that you either have to use higher-rank types to force it to be polymorphic, or explicitly