user12457
user12457

Reputation: 191

Implement join using bind

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

Answers (1)

sepp2k
sepp2k

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

Related Questions