I want to know the difference between
->
, >>=
and <-
in haskell and how to use them?
I want to know the difference between
->
, >>=
and <-
in haskell and how to use them?
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 >>=
.