whats the third function for a monad? bind return and...?
Haskell's Monad also has >> and >>= both defined as part of the typeclass itself; instead of making >> a normal function. The typeclass does provide a default implementation of >> in terms of >>=.
But you are correct. In general all you need for a monad is bind and return.
http://hackage.haskell.org/package/base-4.9.1.0/docs/Prelude...
join :: m(m a) -> m a
You don't need to specify it if you already have bind/>>= and return/pure, since they can be derived from each other.For instance, purely by "following the types",
f :: a -> m b
fmap f :: m a -> m (m b)
join (fmap f) :: m a -> m b
In other words, (>>=) :: m a -> (a -> m b) -> m b
ma >>= f = join (fmap f ma)
is a perfectly good definition of bind I you have join.(>>) :: m a -> m b -> m b
There are two forms of bind.
The >> function is used when the function does not need the value produced by the first monadic operator.