November 2017
— A HTTP server that increments a counter without modifying state
function count(i) { server.once('request', function (req, res) { res.end(String(i)); return count(i + 1); });}count(0);
— Use on existing server to create a request counter
— The "pro" here is that it avoids mutating stateThe con is that this STILL isn't a pure functional monadic interface
Message permanent page
— For two reasons:.once is a side effect (mutates internal state of the event emitter)res.end is not wrapped in a monadic type (like a promise)
— Is once an actual js function
— I can't find the MDN reference
— No
— Part of nodejs
— But browsers have the equivalent I believe
— Give me a sec
— Well, almost