Hacker News new | ask | show | jobs
by JadeNB 4122 days ago
> A fun challenge is figuring out why the definition of (.:) is equivalent to

> (.:) = fmap . fmap

> !

Of course it's not really equivalent, since the most general type of the LHS is as you have said, whereas that of the RHS involves functor constraints; but inlining the definition of `fmap` for arrows gives the amusing definition:

    (.:) = (.) . (.)
I tend to figure this sort of thing out by successive eta conversion:

    \f g x y -> f (g x y)
    \f g x y -> (f . g x) y
    \f g x   -> f . g x
    \f g x   -> ((f .) . g) x
    \f g     -> (f .) . g
    \f g     -> ((f .) .) g
    \f       -> ((f .) .)
    \f       -> (.) (f .)
    \f       -> (.) ((.) f)
    \f       -> ((.) . (.)) f
                (.) . (.)
Is there a better way?