How to apply a traversable of functions to a one value
问题 What should I use if I want to have something like [a->b] -> a -> [b] basically I have a list of functions, all take in a value a and returns b . I want to apply all of them to one a and get the results [b] . Which one should I use? Thanks 回答1: You don't need Traversable , just Functor : swingMap f x = fmap ($ x) f See also the swing function (this is equivalent to swing fmap ). Or, if you're using Edward Kmett's distributive library, you can have the best of both this answer (only a Functor