It's actually more insightful to see the full type signature:
(>>=) :: Monad m => m a -> (a -> m b) -> m b
So, >>= is a function that takes:
- A value a in a monadic type m
- A function (a -> m b): a function that takes a value a and returns a value b wrapped in the monadic type m.
And it returns:
- A value b wrapped in the monadic type m.
It helps to look at the definition of (>>=) for a particular monad. The article mostly discusses computations that can fail (None vs an object in Python). The corresponding Haskell monads are Maybe and Either. The signature for (>>=) in the Maybe monad is:
(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b
What the grandparent points out is that a monad defines a structure (how to combine expressions that result in wrapped values), but not semantics. The semantics are defined in the definition of a particular monad. E.g. the Maybe monad models failure in computation, while a monad such as MonadRandom does something different altogether (providing random numbers, while threading the state of the random number generator).
- A value a in a monadic type m
- A function (a -> m b): a function that takes a value a and returns a value b wrapped in the monadic type m.
And it returns:
- A value b wrapped in the monadic type m.
It helps to look at the definition of (>>=) for a particular monad. The article mostly discusses computations that can fail (None vs an object in Python). The corresponding Haskell monads are Maybe and Either. The signature for (>>=) in the Maybe monad is:
What the grandparent points out is that a monad defines a structure (how to combine expressions that result in wrapped values), but not semantics. The semantics are defined in the definition of a particular monad. E.g. the Maybe monad models failure in computation, while a monad such as MonadRandom does something different altogether (providing random numbers, while threading the state of the random number generator).