Created
December 8, 2018 06:21
-
-
Save franzwong/c1129df4bd6b8db4d848cf5abd08c34a to your computer and use it in GitHub Desktop.
Working with fluture and sanctuary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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