forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmp.js
29 lines (26 loc) · 794 Bytes
/
tmp.js
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
//@ts-check
var fs = require('fs')
var path = require('path')
function* range(n) {
for (var i = 0; i < n; ++i) {
yield i
}
}
var constructors = (n) => {
return [...range(n)].map((x => `| A${x} \n`)).reduce((x, y) => x + y)
}
var matches = (n) => {
return [...range(n)].map((x => `| A${x} -> ${x} \n `)).reduce((x, y) => x + y)
}
var xs = (n) => {
return [...range(n)].map((x => `| A${x} -> "A${x}" \n `)).reduce((x, y) => x + y)
}
var code = (n) => {
var content = `type t = \n ${constructors(n)}`
var match = `let to_enum = function\n ${matches(n)}`
var to_string =
`let to_string = function\n ${xs(n)}`
return content + match + to_string
}
fs.writeFileSync(path.join(__dirname,'..','jscomp','test','big_enum.ml'),
code(300),'utf8')