Skip to content

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

Open

Description

@impasse

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那些类型约束=-=

Activity

  1. AllanZyne commented on Dec 3, 2016

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

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

  2. impasse commented on Dec 3, 2016

    @impasse
    OwnerAuthor

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

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions