logoalt Hacker News

sieve • today at 7:00 PM • 1 reply • view on HN

In the vast majority of programs, errors and non-results are irrelevant at the call site. You want to program for the happy path and not wrap every single call with error checking code or `try/catch/finally`.

    h = file_open(path)
    data = file_read(h)
    file_close(h)
    return data
is the code you want to read. This essentially is:

    return file_open(path).success(h -> h, file_read(h)).success(h, data -> file_close(h); data)
A language with thoughtful error handling primitives will support such code.

Replies

spullara • today at 7:58 PM

that is the same as saying the method throws IOException

➕ show 1 reply