The join utility function is defined as:
join :: (Monad m) => m (m a) -> m a
join x = x >>= id
Given that the type of >>= is Monad m => m a -> (a -> m b) -> m b and id is a -> a, how can that function also be typed as a -> m b as it must be in the definition above? What are m and b in this case?
The
as in the types for>>=andidaren’t necessarily the sameas, so let’s restate the types like this:So we can conclude that
cis the same asaafter all, at least whenidis the second argument to>>=… and also thatcis the same asm b. Soais the same asm b. In other words: