Reputation: 191
I am trying to understand how join is implemented using bind (>>=).
join x = x >>= id
id has type of (a -> a) but bind needs a function of type (a -> m b). I couldn't match the type.
Upvotes: 0
Views: 164
Reputation: 370132
If x
has type m (m t)
, then a
is m t
, so id
in this context has the type m b -> m b
, which fits the type of >>=
.
Upvotes: 7