Does it make sense to define multiple flatMap
(or >>=
/ bind
in Haskell) methods in a Monad?
The very few monads I actually use (Option
, Try
, Either
projections) only define one flatMap method.
For exemple, could it make sense to define a flatMap
method on Option
which would take a function producing a Try
? So that Option[Try[User]]
would be flattened as Option[User]
for exemple? (Considering loosing the exception is not a problem ...)
Or a monad should just define one flatMap
method, taking a function which produces the same kind of monad? I guess in this case the Either
projections wouldn't be monads? Are they?