function composition with reverse syntax
If I want to apply f
first and g
second, I have to write:
g . f
Is there another standard syntax that would allow me to write the functions in the reverse order?
f <whatever> g
I know I can just invent my own syntax:
compose f g x = g (f x)
and then use it like this:
f `compose` g
But I would rather use a 开发者_StackOverflowstandard library facility.
f >>> g
from Control.Arrow.
In addtition to >>>
, some libraries provide their own version of this function, for example:
compose
or.>
from Flow.-.
from composition-prelude.
You may use Hoogle to find examples of functions with a specific signature. For your exact question you can use hoogle.haskell.org/?hoogle=(a -> b) -> (b -> c) -> (a -> c).
精彩评论