Skip to content

Instantly share code, notes, and snippets.

@lambdaydoty
Created June 30, 2020 02:28
Show Gist options
  • Save lambdaydoty/85ee0026cd288481fa0883ad01b5c2e4 to your computer and use it in GitHub Desktop.
Save lambdaydoty/85ee0026cd288481fa0883ad01b5c2e4 to your computer and use it in GitHub Desktop.
;(function () {
const { S, F } = require ('./src/utils/sanctuary') ()
const control = F.coalesce (_ => S.Nothing) (S.Just)
const fut = F.go (function * () {
// const book1 = yield F.resolve ('Python')
const book1 = yield control (F.reject ('?network error'))
const book2 = yield control (F.resolve ('JavaScript'))
return {
book1,
book2,
}
})
const happy = x => console.log ('resolved:', x)
const unhappy = x => console.error ('rejected:', x)
F.fork (unhappy) (happy) (fut)
}) ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment