Re:If monads are the solution, what is the problem?
by tathougies on Monday July 30, 2018 @07:06PM
(#17649013)
In haskell? I'd construct an API that could be used like the following. This looks like the code we write at the place i work at:
The signatures of socket, bind, etc, would look like (for example):
Then, at top level
The key here is that error handling is factored out. The 'runService' function expresses concisely all the steps taken, and the entire concern of error handling is factored out into the 'handleError' function, whose behavior I can actually change based on what I may want. In a C implementation, changing error handling strategies, would mean passing some kind of flag in (you could rebuild exceptions using setjmp/longjmp, but meh).
[ Parent
| on HN ]
There are no comments on this comment yet.