Skip to content

Instantly share code, notes, and snippets.

@franzwong
Created December 8, 2018 06:21
Show Gist options
  • Save franzwong/c1129df4bd6b8db4d848cf5abd08c34a to your computer and use it in GitHub Desktop.
Save franzwong/c1129df4bd6b8db4d848cf5abd08c34a to your computer and use it in GitHub Desktop.
Working with fluture and sanctuary
const F = require('fluture')
const {create, env} = require ('sanctuary');
const {env: flutureEnv} = require ('fluture-sanctuary-types');
const S = create ({checkTypes: true, env: env.concat (flutureEnv)});
const getName = id => new Promise(resolve => {
console.log(id)
setTimeout(() => resolve('Franz'), 3000)
})
const getNameP = F.encaseP(getName)
// Without Maybe
const id = 10
getNameP(10).fork(console.error, console.log)
// With Maybe
const id$ = S.Just(20)
S.pipe([
S.map(getNameP),
S.map(f => f.fork(console.error, console.log))
])(id$)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment