hinc icon indicating copy to clipboard operation
hinc copied to clipboard

Thoughts on the usage of await

Open Eugleo opened this issue 5 years ago • 2 comments

Preface: I write Haskell for living, and even though I probably won’t be using this, I love the idea! Great job!

I’d like to discuss the syntax for executing effectful (monadic) computation as seen in this snippet

let mapM(f: (a) => m<b>, lst: List<a>): m<List<b>> where m : Effect
  = case (lst) {
      when Nil -> Nil.pure
      when Cons(x, xs) -> effect {
        let y  = await f(x)
        let ys = await xs.mapM(f)
        Cons(y, ys).pure
      }
    }

I think that this might lead the intended audience (developers familiar with C-style and specifically JS-style languages) astray, because the effects aren’t limited to async computations, but the await keyword suggests otherwise. I wonder why you made this choice (maybe there’s something I’m missing).

I think that a better choice would be something that has a notion of action baked in, while being general enough and not overburdened with existing meaning, like do or exec or run. What do you think?

Eugleo avatar Aug 10 '20 14:08 Eugleo

It’s not yet documented, but you can use do as synonym of await. What do you think?

El El lun, 10 ago 2020 a las 16:16, Evžen Wybitul [email protected] escribió:

Preface: I write Haskell for living, and even though I probably won’t be using this, I love the idea! Great job!

I’d like to discuss the syntax for executing effectful (monadic) computation as seen in this snippet

let mapM(f: (a) => m, lst: List): m<List> where m : Effect

= case (lst) {

  when Nil -> Nil.pure

  when Cons(x, xs) -> effect {

    let y  = await f(x)

    let ys = await xs.mapM(f)

    Cons(y, ys).pure

  }

}

I think that this might lead the intended audience (developers familiar with C-style and specifically JS-style languages) astray, because the effects aren’t limited to async computations, but the await keyword suggests otherwise. I wonder why you made this choice (maybe there’s something I’m missing).

I think that a better choice would be something that has a notion of action baked in, while being general enough and not overburdened with existing meaning, like do or exec or run. What do you think?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/serras/hinc/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACLQVXWF6RX4KN65E5ABGTR776K7ANCNFSM4P2AEGSA .

-- Kind regards, Alejandro

serras avatar Aug 10 '20 14:08 serras

Surely a step in the right direction IMHO. Why not ditch the await completely, though, given that it’ll be confusing in 99% of cases?

Eugleo avatar Aug 10 '20 14:08 Eugleo