Part of some computation I am doing in Haskell results in a list of functions that map Float
to Float
. I'd like to apply a single argument to all these functions, like so:
-- x :: Float
-- functions :: [Float -> Float]
map (\f -> f x) functions
Is there a way to do this without making use of a throw-away lambda function? I've searched Hoogle for what I think the signature should be ([a -> b] -> a -> [b]
) with no luck.
You can use the $
operator, which is just function application:
map ($ x) functions
(This presupposes that x
is in scope for the expression.)
Hoogle can only find functions, not arbitrary expressions. Since you're using map
, you wanted to search for a function like (a -> b) -> a -> b
rather than anything involving lists. Given a normal function, passing it to map
makes it act on lists.