Option
monad turns pretty much a facility some times in Scala. Are there any other monads in Scala standard library?
3 Answers
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).

- 295,120
- 86
- 501
- 681
-
1What do you intend by "the signature for flatMap in them is not a monad's flatMap" ? Are you referring to the implicit machinery ? – paradigmatic Feb 13 '12 at 11:02
-
1@paradigmatic, yes. See the Tony Morris rant [here](http://stackoverflow.com/questions/1722726/is-the-scala-2-8-collections-library-a-case-of-the-longest-suicide-note-in-hist/1735694#1735694). – missingfaktor Feb 13 '12 at 11:48
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

- 50,650
- 20
- 113
- 180
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.

- 90,905
- 62
- 285
- 365