Skip to content

Instantly share code, notes, and snippets.

@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
// ======================================
// HIGHER ORDER CURRIED ARROW FUNCTIONS
// ======================================
// Double arrows are great for creating functions
// that dont need all their arguments at once
// This is best for functions that need configuration
// before running on an active value.
// So here we have a function called