News for hackers. Stuff that matters.
Re:Errors are values by masklinn on Tuesday January 13, 2015 @04:07AM (#8878768)
> In Go I not infrequently make use of a non-nil value AND a non-nil error.

The number of APIs making use of that pattern is very much infrequent, and doesn't justify it for the 99.99% of functions which don't.

> I think it is a very useful idiom particularly when dealing with things where failure is more normal

And you could have the exact same information by returning, say, `Either (Int, Error) Int`. Or even `Either (Int, Error) ()` since partial writes are apparently considered error cases.

Although I would really use a separate data type e.g.

    data WriteResult = Complete | Partial Int Cause | Error Cause
and let the application decide whether a partial write is an error or normal behaviour.

There are no comments on this comment yet.