[<<][haskell][>>][..]

Sun May 27 18:33:31 EDT 2018

## compose and 2-argument function?

How to pipe the output of a 2 argument function through a second one?
a -> b -> c and c -> d
(c -> d) -> (a -> (b -> c)) -> (a -> (b -> d))
(c -> d) -> f c -> f d
so it is fmap
and the functor is F(t) = (a -> (b -> t))
but i can't get to i that way.
It's Kmett's dot dot dot...
*Main> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
*Main> :t (.) . (.)
(.) . (.) :: (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c
*Main> :t (.) . (.) . (.)
(.) . (.) . (.)
:: (b -> c) -> (a2 -> a1 -> a -> b) -> a2 -> a1 -> a -> c
reg'' :: Seq m r => SType -> (r S -> m (r S)) -> m (r S)
reg'' = ((.).(.)) (fmap fst) reg'
Ok, I get it. The sequence applies f to the result of
1,2,3,.. argument function
(.) f g1
((.).(.) f g2
((.).(.).(.)) f g3
The first one is just functiona application. The other ones
immedately look quite ugly, but if application is written as above it
is clear there is a sequence.
https://stackoverflow.com/questions/17585649/composing-function-composition-how-does-work
That mentions composing fmap gets you deeper into layers of functors.
That makes sense. Then (.) is ifmap for ((->) r), which brings the
same point as above.
So (.).(.) is fmap.fmap

[Reply][About]

[<<][haskell][>>][..]