I want to compose functions in the following way:
compose :: (a->b->c) -> (d->a) -> (d->b) -> d -> c
compose f g h x = f (g x) (h x)
So that we can use it in the following way:
compose (==) (myReverse . myReverse) id [1..100]
I think it could be simplified with something like ‘fmap’, so that it needn’t define ‘compose’ at all. But I failed to figure out how to do that.
If you import
Control.Applicative, thenSo, you can write
(==) <$> (myReverse . myReverse) <*> id $ [1..100]<*>specialized to functions is equivalent to the S-combinator:You can probably use
Control.Arrowtoo:Update
I’ve asked
lambdabotat#haskellthe same question and he answered simplyliftM2. 😀