Skip to content

Instantly share code, notes, and snippets.

@awto
Last active March 8, 2019 14:50
Show Gist options
  • Save awto/3d1f19bd8d9fd26e164fb4829158338c to your computer and use it in GitHub Desktop.
Save awto/3d1f19bd8d9fd26e164fb4829158338c to your computer and use it in GitHub Desktop.
continuation monad with suspense
const runCont = run(
value => cont => cont(value),
(arg, next) => cont => arg(value => next(value)(cont)));
const useState = initial =>
M(cont =>
cont([initial, function next(value) { cont([value,next]); }]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment