Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

突然想到 Javascript 里的 async-await 和 Haskell 里的 do-notation 是一个东西 #4

Open
impasse opened this issue Dec 2, 2016 · 2 comments

Comments

@impasse
Copy link
Owner

impasse commented Dec 2, 2016

Javascript 里面的 Promise 对应 Haskell 里的 Monad,把操作封装在 Promise/Monad 里。

async function do(){
  let a = await JobOne();
  let b = await JobTwo();
  return c;
}
do' = do
  a <- job_one
  b <- job_two
  return c

只不过没有haskell那些类型约束=-=

@AllanZyne
Copy link

AllanZyne commented Dec 3, 2016

JobOne().then(a => JobTwo().then(b => c))
job_one >>= (\a -> job_two >>= (\b -> c))

= = (PS 你博客上的多说有问题了

@impasse
Copy link
Owner Author

impasse commented Dec 3, 2016

多说的问题有点头疼。。最近在考虑不用了。。

@impasse impasse changed the title 突然想到 Javscript 里的 async-await 和 Haskell 里的 do-notation 是一个东西 突然想到 Javascript 里的 async-await 和 Haskell 里的 do-notation 是一个东西 Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants