This will contain some helpful hints and frequently asked questions re: Hack. This is a living document and may be molded into something more user-interactive in the future.
No. And this is important. Multithreading allows for tasks to execute in different threads of execution. Hack (and PHP) code can only run in one thread of execution. Async utilizes that thread to better capacity by allowing for tasks that are stalled by some sort of process (I/O, data fetching, network) to cede control to other tasks to minimize lag.
Normally you will have a bunch of I/O tasks batched up when using async, with results coming back faster than if they were executed one after the other in sequence.
You are encourage to re-read the Async introduction for further clarification.
Should I implement my own
Set::values() return a
Set::keys() return a
It is because
ConstSet (from which
Set ultimately derives) implements
KeyedIterable::map() specifies that it return a
KeyedIterable<Tk, Tm>, implying different types for the keys and values. But a
Set cannot have keys and values of different types (technically a
Set doesn't have keys, even though it does under the covers). Since
KeyedIterable<Tk, Tm> is not compatible with
ConstSet<Tm>, you have to make the key aspects of
Set be as wide as possible.
This could be fixed in the future with changes to our collections interfaces or with advances in the typechecker.
Make sure your XHP code is not in a namespace. We have issues, in many cases, using XHP in code belonging to a namespace. The issue is known and we are trying to figure out a solution.
You are probably passing it as a string, like this:
On its own, the Hack typechecker cannot understand what to do with a function that is referred to by its string name only. It needs some help.
In this case, you want to help the typechecker by using
fun() which tells the typechecker to lookup the actual function associated with that name and typecheck that.