How to return Either<Error, T> in an idiomatic way #1110
EivindAntonsen
started this conversation in
General
Replies: 1 comment 4 replies
-
Yep, Btw, There's some notes on the recent |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am wondering how the idiomatic approach to returning
Either<Error, T>
would look like. Currently I am using a method I made myselfpublic static Either<Exception, T> TryEither<T>(Func<T> function)
which simply wraps a different function call which i then follow up with.MapLeft(exception => exception.ToError)
. This feels a little backwards and hacky, but the end result however is allright (Eithers everywhere).My thinking is that anything that might fail where the error is something that should be handled by the application, the return value should be
Either<Error, T>
- which is why I use this function a lot.I've seen Eff and Aff mentioned previously but I don't understand them. Can anybody chime in on how to use them, and if that is appropriate? The application is a standard webservice/api, nothing fancy.
Beta Was this translation helpful? Give feedback.
All reactions