Strict function application. This function usually isn't necessary,
but it can be more readable than some alternatives when used with
higher-order functions like
map.
>>> map (apply' 2) [succ, recip, negate]
[3.0,0.5,-2.0]
The different between this and
apply is that this evaluates its
argument before passing it to the function.
>>> apply undefined (const True)
True
>>> apply' undefined (const True)
*** Exception: Prelude.undefined
...
In general you should prefer using an explicit lambda or operator
section.
>>> map (\ f -> 2 !> f) [succ, recip, negate]
[3.0,0.5,-2.0]
>>> map (2 !>) [succ, recip, negate]
[3.0,0.5,-2.0]
>>> map (<! 2) [succ, recip, negate]
[3.0,0.5,-2.0]
\ x -> apply' x f == seq x (f x)