3 ms·
Sorry, I don't mean to talk about Sum/Max/Min. I mean to talk about Either<A,B>, which is the appropriate return type for almost every Go function. In the prese
by anonymoushn 13y ago
Sorry, I don't mean to talk about Sum/Max/Min. I mean to talk about Either<A,B>, which is the appropriate return type for almost every Go function. In the presence of this type, the
"40 lines of mostly error handling" can then be reduced most of the way back to 5 lines using some function or control-flow construct that maps over the left half (or whichever half is chosen to not hold the exception) only.
Here's this in a really ugly language I would never recommend to anyone: http://stackoverflow.com/questions/3496304/how-do-i-process-returned-either http://stackoverflow.com/questions/3496304/how-do-i-process-...
And in a reasonable language: http://stackoverflow.com/questions/13503965/mapping-over-eithers-left http://stackoverflow.com/questions/13503965/mapping-over-eit...
Edit: See also wting's comment below https://news.ycombinator.com/item?id=7562702 https://news.ycombinator.com/item?id=7562702