World's most popular travel blog for travel bloggers.

[Solved]: Haskell monad bind operator type

, , No Comments
Problem Detail: 

In Haskell, the Monads type class has the bind operator, which is represented by the symbol >>=

The type of such operator is:

(>>=) :: Monad m => m a -> (a -> m b) -> m b 

Why does the function need to be (a -> m b)? Why functions the preserve che inner data type (a -> m a) are not allowed?

Has this choice been made for some convenience in the language design, or does it have some other reason?

Asked By : Aslan986

Answered By : Musa Al-hassy

Here's a nice, and accessible, blog on why we need the type to have that form.

http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/

Also, this blog motivates why we want them this why and how they naturally arise in our daily workings :)

Enjoy!

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/27808

 Ask a Question

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback