Option
monad turns pretty much a facility some times in Scala. Are there any other monads in Scala standard library?
Luigi's answer is correct, but not very informative, IMHO.
All collections can implement the monad interface, but the signature for flatMap
in them is not a monad's flatMap. They'll act like monads most of the time, though. Almost all of the classes listed by Luigi are related to collections.
LeftProject
and RightProject
refers to Either
. Basically, Either
is not a monad, but if you "project" one of the sides, then that side acts pretty much like an Option
monad.
Parser
is a monad, which forms the basis of parser combinators.
I admit I do not recognize ControlContext
. I wonder if it is related to continuations (which are monads as well).
You can work this out by looking up the tell-tale flatMap
in the API index. It gives:
FilterMonadic
Stream
StreamWithFilter
TraversableMethods
Iterator
ParIterableLike
ParIterableLike
ParIterableViewLike
TraversableLike
WithFilter
MonadOps
TraversableProxyLike
TraversableViewLike
LeftProjection
RightProjection
Option
WithFilter
Responder
Zipped
ControlContext
Parser
Here are the links to three sources files from Scalaz:
Take a look at instance declarations. That might give you an idea about what types from the standard library satisfy the monadic interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With