News for hackers. Stuff that matters.
Re:Does category theory make you a better programmer? by sznurek on Tuesday July 31, 2012 @01:03AM (#4315810)
I wrote 'monad-inspired' structure because of lack of syntactic sugar (do notation). So it basically looks like that:

  login_action = Write('PASS') >> \
                 Read('pass') >> \
                 Guard(lambda v: v['pass'] == 'mysecret') >> \
                 Write('WELCOME')
  
  register(socket, login_action, on_success=func1, on_error=func2)
Of course you can develop this idea futher:

  cat = Read('line') >> Write(lambda v: v['line'])
  cat.append_action(cat)

  register(socket, cat, on_error=handle_error_cb)
Re:Does category theory make you a better programmer? by edwkar on Tuesday July 31, 2012 @03:59AM (#4316194)
Nice!!