I've recently been writing some code that deals with 3rd parties -- obviously errors will happen so I'm using Either/Maybe monads where appropriate. As this is C# I'm also using async Tasks too.
My problem is after it's all said & done my return types are quite verbose. e.g.
Task<Either<ApiErrorEnum, ActualApiResultDto>> GetSomeFoo(int fooId);
But wait it can get even better
Task<Either<ApiErrorEnum, IEnumerable<ActualApiResultDto>> GetSeveralFoos()
It's a little much, but it all seems necessary to me. Obviously the Task<..> is because this is an IO bound operation. the Either is needed because this can go wrong in several different ways, and the actual result DTO is needed because that's what I'm really after.
I have written some code to basically typedef
Either<ApiErrorEnum,T> but it's a little lacking as the infrastructure code for Either I've written can't quite handle derived types (I've tried, there's just always an edge case or two).
TLDR question: How can I reduce the verbosity of my return types?