-7

I want to know the difference between

-> , >>= and <-

in haskell and how to use them?

Lin Jiayin
  • 499
  • 1
  • 6
  • 11
  • 2
    I'd recommend reading a monad tutorial. E.g. [LYAH](http://learnyouahaskell.com/a-fistful-of-monads) has a chapter dedicated to that topic. You will find many monad tutorial around the net if you google for them. – chi Oct 25 '15 at 13:13
  • 3
    Your question shows zero effort of finding the answer yourself. You'll find the answer in any basic introduction to the language. – Nikita Volkov Oct 25 '15 at 13:19

1 Answers1

1

a -> b is the function type. It describes a function that takes a type a and returns a type b.

>>= is the monadic bind function. It is of type Monad m => m a -> (a -> m b) -> m b. If you need to understand this, I recommend reading Learn You a Haskell for Great Good.

<- is syntactic sugar in a do block, where do {a <- b; c} translates as b >>= \a -> c, i.e, it's basically a nicer way of writing >>=.

AJF
  • 11,767
  • 2
  • 37
  • 64