forked from PrismJS/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprism-rescript.html
More file actions
49 lines (42 loc) · 1.01 KB
/
prism-rescript.html
File metadata and controls
49 lines (42 loc) · 1.01 KB
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
<h2>Comments</h2>
<pre><code>/* This is a comment */
// Another comment
</code></pre>
<h2>Strings and characters</h2>
<pre><code>let name = "Alonzo Church"
let message = `Hello ${name}`
let message2 = `Hello ${person.name}`
let result = `Testing => ${Module.Another.value}`
</code></pre>
<h2>Type declarations & Functions</h2>
<pre><code>type role = | Admin | Editor | Viewer
type numeric = #1 | #2 | #3
type normal = #Poly | #Variant
type myPolyVar = [ #"poly-variant" | #"test-chars" ]
type person = {
name: string,
age: int,
role: role
}
let sum = (a, b) => a + b
let sum = (a:int, b: int) => a + b
</code></pre>
<h2>JSX & Components</h2>
<pre>
<code>
module Button = {
@react.component
let make = (~count: int) => {
let times = switch count {
| 1 => "once"
| 2 => "twice"
| n => Belt.Int.toString(n) ++ " times"
}
let msg = "Click me " ++ times
<button onClick={Js.log}>{msg->React.string}</button>;
}
}
@react.component
let make = () => <MyModule.Button count=1 />
</code>
</pre>