-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathasync.res
44 lines (33 loc) · 974 Bytes
/
async.res
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
let greetUser = async (userId) => {
let name = await getUserName(. userId)
"Hello " ++ name ++ "!"
}
async () => 123
let fetch = {
async (. url) => browserFetch(. url)
}
let fetch2 = {
async (. url) => browserFetch(. url)
async (. url) => browserFetch2(. url)
}
// don't parse async es6 arrow
let async = {
let f = async()
()->async
async()
async.async
{async: async[async]}
result->async->mapAsync(a => doStuff(a))
}
let f = isPositive ? (async (a, b) : int => a + b) : async (c, d) : int => c - d
let foo = async(~a=34)
let bar = async(~a)=>a+1
let ex1 = await 3 + await 4
let ex2 = await 3 ** await 4
let ex3 = await foo->bar(~arg)
let ex4 = await foo.bar.baz
let attr1 = @a async x => x+1
let attr2 = @a async (type a) => (type b c, x) => 3
let attr3 = @a (type a) => async (type b c, x) => 3
let attr4 = @a (type a) => @b async (type b c, x) => 3
let attr5 : int = @a @b async (type a, type b c) => (x:a) => x