Я часто сталкиваюсь с тем, что пишу код по схеме:
foo xs = map snd $ filter ((< 10).fst) $ zip xs [0..]
bar ys = map snd $ sortBy (compare `on` fst) $ zip ys [0..]
Теперь я хочу абстрагироваться от этого
foo = indexesOf (filter (<10))
bar = indexesOf sort
indexesOf :: ([a] -> [a]) -> [a] -> [Int]
indexesOf f xs = map snd $ magick $ zip xs [0..] where
magick = undefined
Как выполнить магию
?