Re:Side Effects vs. Promises
by edgyswingset on Sunday October 04, 2015 @02:45PM
(#10328377)
I'm not a Haskeller and haven't played with monads knowing they were monads, but async in F# basically works like this:
1. Call the function with async { } block and have it return a computation object
2. Start that computation object in three primary ways:
a. On another thread, then wait (non-blocking) on it to finish
b. On another thread but don't wait for it to finish
c. On the current thread and don't wait for it to finish
There's a lot more details but that's going to cover probably 95% of the use cases.My takeaways from it are:
a. Super easy to write code for it that's easy to read
b. Really hard to fuck it up
In my opinion, it's superior to the model that C#/VB have ... and pretty much every other language I've tried async support on. Have yet to use Haskell for it.
Async is like having do-notation, but without having to convert your code to do-notation! Do-notation is nice but having a single notation for everything is even better.
Both haskell and ocaml currently require you to use do-notation to write async code. I'm really looking forwards to algebraic effects landing in ocaml though because with that they will be introducing delimited one-shot continuations as part of the core language.
Re:Side Effects vs. Promises
by saosebastiao on Sunday October 04, 2015 @04:13PM
(#10328639)
It is very similar to do notation, but async expressions give you the ability to mix monadic and non-monadic code seamlessly and with uniform syntax within the same computation object. It's been a while since I've toyed with Haskell, but mixing regular Haskell and do-notation Haskell always felt like mixing two completely different languages.
Outside of those, I don't know what the story is.