Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to algebraic effects on ruby

Introduction to algebraic effects on ruby

Avatar for Vitaliy Pecherin

Vitaliy Pecherin

August 29, 2019
Tweet

More Decks by Vitaliy Pecherin

Other Decks in Programming

Transcript

  1. • making a HTTP request • mutating data • printing

    to a log or console • Random.rand • getting the current time
  2. • pure functions are easy to test • side effects

    can make code complicated • pure functions are easy to use in parallel
  3. side effects are a necessary evil, and one should seek

    to minimize/ localize/isolate them
  4. • The function takes a callback as an additional argument

    • The function never returns its result. It always uses the callback to communicate its result CPS
  5. Fibers are primitives for implementing light weight cooperative concurrency in

    Ruby. Basically they are a means of creating code blocks that can be paused and resumed, much like threads. https://devdocs.io/ruby~2.6/fiber
  6. The idea of a continuation is that it captures the

    remaining computation left to be evaluated
  7. • reset mark on the stack as the limit of

    the continuation to be captured • shift jumps back to where that mark was, i.e. where you used reset, and saves the portion of the program between that and where you called shift
  8. • exception • retry • scheduler • state • random

    • time • async/await • parallel
 • log