Use a proper monad stack that handles curl, MongoDB, parameters, logging, errors/exceptions. I use mtl for MonadTransformers.