Closed danidiaz closed 2 months ago
Sounds fairly innocent, I'd review a PR for this. But transformers
is such a popular package, I am not sure I fully understand why one would avoid it. Is it just because it's cumbersome for something you think is something Servant should have out of the box?
For small enough cases, I do like to use Servant
without tranformers
and mtl
. I just stay in the IO
monad and lift the result to Handler
at the last minute. I guess you could call it "simple Servant" 😆
I've just realised that I already can write a function IO (Either ServerError a) -> Handler a
without those dependencies, because throwError
is re-exported by the Servant
module. Still, I believe having an explicit inverse to runHandler
could make sense.
@danidiaz Are you happy with the PR? If yes, I'll let you close this ticket. :)
Currently we have
runHandler :: Handler a -> IO (Either ServerError a)
, and it would be good to have a function going in the other direction.Of course, it's easy to lift an
IO a
toHandler a
usingliftIO
but, unless I'm mistaken, going fromIO (Either ServerError a)
to aHandler
requires a dependeny ontransformers
and importing theExceptT
constructor.Instead of a special-purpose function, re-exporting the
ExceptT
constructor could be another solution.