So instead of join (,) we now have \r -> ((,) r) r
Which is the same thing as \r -> (,) r r
Which is the same thing as \r -> (r,r)
Never forget that the Haddocks link through to the source code of the library. That's immensely useful when trying to figure out how things work together.
I like Aadits intuitive answer. Here's how I'd figure it out by reading the source code.
join
join
join
join x = x >>= id
join (,) = (,) >>= id
>>=
on Hoogle and click the link(,)
which is a function, so I click "source" on theMonad ((->) r)
instancef >>= k = \r -> k (f r) r
f = (,)
andk = id
, we get\r -> id ((,) r) r
id
! I search for that on Hoogle, and click through to its source codeid x = x
join (,)
we now have\r -> ((,) r) r
\r -> (,) r r
\r -> (r,r)
Never forget that the Haddocks link through to the source code of the library. That's immensely useful when trying to figure out how things work together.
Look at the type signatures:
It should be noted that
((->) r)
is an instance of theMonad
typeclass. Hence, on specializing:What
join
does for functions is apply the given function twice to the same argument:From this, we can see trivially:
Qed.