In Database.MongoDB.Query, there is this function:
access :: MonadIO m => Pipe -> AccessMode -> Database -> Action m a -> m a
The documentation says this about the function:
Run action against database on server at other end of pipe. Use access mode for any reads and writes. Return Left on connection failure or read/write failure.
- What does "return Left" mean here? I ask because
m
can be any monad (with aMonadIO
instance). For instance, what does "return Left" mean ifm
is just theIO
monad? - Must
m
be theEither
monad for me to be able to detect connection or read/write failure when using theaccess
method?
IO
orMonadIO m
(I suppose it makes sense if you had e.g.IO (Either a b)
). Furthermore,Either
cannot be an instance ofMonadIO
so you can't even instantiatem
withEither
. Although,MonadIO m => EitherT e m
has an instance, but even if you use this instantiation, you will never getLeft something
fromaccess
- it's type even guarantees this. – user2407038m (Either Failure a)
- it does really seem like just a case of outdated documentation. (If it's important to you, you should contact the maintainer) – user2407038