forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUncurriedExternals.res
80 lines (60 loc) · 2.46 KB
/
UncurriedExternals.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module StandardNotation = {
external raise: (. exn) => 'a = "%raise"
let dd = () => raise(. Not_found)
@val external sum: (. float, float) => float = "sum"
let h = sum(. 1.0, 2.0)
module M: {
let sum: (. float, float) => float
} = {
external sum: (. float, float) => float = "sum"
}
let hh = M.sum(. 1.0, 2.0)
external mod_float: (. float, float) => float = "?fmod_float"
let mf = mod_float(. 3., 4.)
@get_index external get: (. array<string>, int) => option<'a> = ""
let tg = arr => arr->get(. 0)
@val external copy: (. @as(json`{}`) _, string) => string = "Object.assign"
let tc = copy(. "abc")
external toException: (. exn) => exn = "%identity"
let te = toException(. Not_found)
@obj external ccreate: (. unit) => string = ""
let tcr = ccreate(.)
type counter
@set external setIncrementC: (counter, @this (counter, int) => unit) => unit = "increment"
let tsiC = c => setIncrementC(c, @this (me, amount) => Js.log(me))
@set external setIncrementU: (. counter, @this (. counter, int) => unit) => unit = "increment"
let tsiU = c => setIncrementU(.c, @this (. me, amount) => Js.log(me))
@module("react")
external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) =
"useState"
let (get, set) = useState(() => 3)
}
@@uncurried
external raise: exn => 'a = "%raise"
let dd = (. ()) => raise(Not_found)
@val external sum: (float, float) => float = "sum"
let h = sum(1.0, 2.0)
module M: {
let sum: (float, float) => float
} = {
external sum: (float, float) => float = "sum"
}
let hh = M.sum(1.0, 2.0)
external mod_float: (float, float) => float = "?fmod_float"
let mf = mod_float(3., 4.)
@get_index external get: (array<string>, int) => option<'a> = ""
let tg = arr => arr->get(0)
@val external copy: (@as(json`{}`) _, string) => string = "Object.assign"
let tc = copy("abc")
external toException: exn => exn = "%identity"
let te = toException(Not_found)
@obj external ucreate: unit => string = ""
let tcr = ucreate()
type counter
@set external setIncrementC: (. counter, @this (. counter, int) => unit) => unit = "increment"
let tsiC = c => setIncrementC(.c, @this (. me, amount) => Js.log(. me))
@set external setIncrementU: (counter, @this (counter, int) => unit) => unit = "increment"
let tsiU = c => setIncrementU(c, @this (me, amount) => Js.log(. me))
@module("react")
external useState: (@uncurry (unit => 'state)) => ('state, ('state => 'state) => unit) = "useState"
let (get, set) = useState(() => 3)