├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── examples ├── bs-module │ ├── BsModule.re │ └── something.js ├── dependencies │ ├── Index.re │ └── Student.re ├── factorial │ └── Factorial.re ├── fizzbuzz │ └── Fizzbuzz.re ├── greatest-common-divisor │ └── GCD.re ├── json │ └── Json.re ├── mixed-deps │ ├── Index.ml │ └── Student.re ├── mli │ ├── School.ml │ └── School.mli ├── normal-random │ └── NormalRandom.re ├── ocaml-fizzbuzz │ └── Fizzbuzz.ml ├── regexp │ └── Regexp.re ├── rei │ ├── School.re │ └── School.rei ├── shebang │ └── Shebang.re ├── string-interpolation │ └── StringInterpolation.re ├── towers-of-hanoi │ └── Towers.re └── tree-sum │ └── TreeSum.re ├── generate.go ├── main.go ├── message ├── FileType.go ├── Message.go └── MessageType.go ├── messages.fbs ├── module └── module.go ├── reasonable ├── runtime ├── compiler.js ├── flatbuffers.js ├── messages_generated.js ├── refmt.js ├── run.js ├── stdlib │ ├── arg.js │ ├── array.js │ ├── arrayLabels.js │ ├── belt.js │ ├── belt_Array.js │ ├── belt_Debug.js │ ├── belt_HashMap.js │ ├── belt_HashMapInt.js │ ├── belt_HashMapString.js │ ├── belt_HashSet.js │ ├── belt_HashSetInt.js │ ├── belt_HashSetString.js │ ├── belt_Id.js │ ├── belt_List.js │ ├── belt_Map.js │ ├── belt_MapDict.js │ ├── belt_MapInt.js │ ├── belt_MapString.js │ ├── belt_MutableMap.js │ ├── belt_MutableMapInt.js │ ├── belt_MutableMapString.js │ ├── belt_MutableQueue.js │ ├── belt_MutableSet.js │ ├── belt_MutableSetInt.js │ ├── belt_MutableSetString.js │ ├── belt_MutableStack.js │ ├── belt_Option.js │ ├── belt_Range.js │ ├── belt_Result.js │ ├── belt_Set.js │ ├── belt_SetDict.js │ ├── belt_SetInt.js │ ├── belt_SetString.js │ ├── belt_SortArray.js │ ├── belt_SortArrayInt.js │ ├── belt_SortArrayString.js │ ├── belt_internalAVLset.js │ ├── belt_internalAVLtree.js │ ├── belt_internalBuckets.js │ ├── belt_internalBucketsType.js │ ├── belt_internalMapInt.js │ ├── belt_internalMapString.js │ ├── belt_internalSetBuckets.js │ ├── belt_internalSetInt.js │ ├── belt_internalSetString.js │ ├── bigarray.js │ ├── block.js │ ├── bs_obj.js │ ├── bs_string.js │ ├── buffer.js │ ├── bytes.js │ ├── bytesLabels.js │ ├── callback.js │ ├── caml_array.js │ ├── caml_backtrace.js │ ├── caml_basic.js │ ├── caml_builtin_exceptions.js │ ├── caml_bytes.js │ ├── caml_exceptions.js │ ├── caml_float.js │ ├── caml_format.js │ ├── caml_gc.js │ ├── caml_hash.js │ ├── caml_hash_primitive.js │ ├── caml_int32.js │ ├── caml_int64.js │ ├── caml_io.js │ ├── caml_lexer.js │ ├── caml_md5.js │ ├── caml_missing_polyfill.js │ ├── caml_module.js │ ├── caml_obj.js │ ├── caml_oo.js │ ├── caml_oo_curry.js │ ├── caml_parser.js │ ├── caml_primitive.js │ ├── caml_queue.js │ ├── caml_string.js │ ├── caml_sys.js │ ├── caml_utils.js │ ├── caml_weak.js │ ├── camlinternalFormat.js │ ├── camlinternalFormatBasics.js │ ├── camlinternalLazy.js │ ├── camlinternalMod.js │ ├── camlinternalOO.js │ ├── char.js │ ├── complex.js │ ├── curry.js │ ├── digest.js │ ├── filename.js │ ├── format.js │ ├── gc.js │ ├── genlex.js │ ├── hashtbl.js │ ├── int32.js │ ├── int64.js │ ├── js.js │ ├── js_array.js │ ├── js_cast.js │ ├── js_console.js │ ├── js_date.js │ ├── js_dict.js │ ├── js_exn.js │ ├── js_float.js │ ├── js_global.js │ ├── js_int.js │ ├── js_int64.js │ ├── js_internal.js │ ├── js_json.js │ ├── js_list.js │ ├── js_mapperRt.js │ ├── js_math.js │ ├── js_nativeint.js │ ├── js_null.js │ ├── js_null_undefined.js │ ├── js_obj.js │ ├── js_option.js │ ├── js_primitive.js │ ├── js_promise.js │ ├── js_result.js │ ├── js_string.js │ ├── js_typed_array.js │ ├── js_types.js │ ├── js_undefined.js │ ├── js_unsafe.js │ ├── js_vector.js │ ├── lazy.js │ ├── lexing.js │ ├── list.js │ ├── listLabels.js │ ├── map.js │ ├── marshal.js │ ├── moreLabels.js │ ├── nativeint.js │ ├── node.js │ ├── node_buffer.js │ ├── node_child_process.js │ ├── node_fs.js │ ├── node_module.js │ ├── node_path.js │ ├── node_process.js │ ├── obj.js │ ├── oo.js │ ├── parsing.js │ ├── pervasives.js │ ├── printexc.js │ ├── printf.js │ ├── queue.js │ ├── random.js │ ├── scanf.js │ ├── set.js │ ├── sort.js │ ├── stack.js │ ├── stdLabels.js │ ├── std_exit.js │ ├── stream.js │ ├── string.js │ ├── stringLabels.js │ ├── sys.js │ ├── unix.js │ ├── unixLabels.js │ └── weak.js ├── topo.js └── utils.js └── test-examples.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Generated code 15 | runtime/static_contents.go 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # TODO: It'd be nice to not have to run this each time 2 | assets: 3 | rm runtime/static_contents.go || true 4 | go generate 5 | 6 | build: assets 7 | go build -o reasonable main.go 8 | 9 | run: assets 10 | go run main.go $(example) 11 | 12 | flatbuffers: messages.fbs 13 | flatc --go --js --es6-js-export messages.fbs 14 | mv messages_generated.js runtime/ 15 | 16 | examples: 17 | for directory in examples/*/; do \ 18 | echo "Running example: $$directory"; \ 19 | ./reasonable "$$directory"; \ 20 | done 21 | 22 | .PHONY: build run examples 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # reasonable 2 | 3 | The ReasonML runtime. 4 | 5 | ## Status 6 | 7 | * Most Reason code will work. 8 | * Accepts a single file or a directory containing `.re` files. 9 | * Native ES imports/exports are used for modules. 10 | * Most of BuckleScript's `stdlib` should work (including Belt!) - though some JS stuff like `Js.log` is still a WIP. 11 | * Shebang support! See the [shebang example](./examples/shebang/Shebang.re). 12 | 13 | ## Notes 14 | 15 | Since `Js.log` isn't implemented yet, you can use `[@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print";` to get access to the `print` method in v8worker2. 16 | 17 | ## Usage 18 | 19 | This repo contains a pre-built binary for macOS. You can use it like: 20 | 21 | ```sh 22 | > ./reasonable examples/fizzbuzz/Fizzbuzz.re 23 | ``` 24 | 25 | Or on a directory of files: 26 | 27 | ```sh 28 | > ./reasonable examples/dependencies/ 29 | ``` 30 | 31 | ## Technologies 32 | 33 | * Go 34 | * v8worker2 35 | * BuckleScript (self-hosted version) 36 | * Flatbuffers 37 | * Topo.js 38 | 39 | ## License 40 | 41 | MPL 2.0 42 | -------------------------------------------------------------------------------- /examples/bs-module/BsModule.re: -------------------------------------------------------------------------------- 1 | [@bs.module "something.js"] external printSomething : unit => unit = "printSomething"; 2 | 3 | printSomething(); 4 | -------------------------------------------------------------------------------- /examples/bs-module/something.js: -------------------------------------------------------------------------------- 1 | export function printSomething() { 2 | V8Worker2.print("something") 3 | } 4 | -------------------------------------------------------------------------------- /examples/dependencies/Index.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | let student = [|{Student.name: "Blaine"}, {Student.name: "Jake"}, {Student.name: "Nick"}|]; 4 | 5 | let a = Belt.Array.map(student, s => s.name); 6 | 7 | Belt.Array.forEach(a, print); 8 | -------------------------------------------------------------------------------- /examples/dependencies/Student.re: -------------------------------------------------------------------------------- 1 | type a = {name: string}; 2 | -------------------------------------------------------------------------------- /examples/factorial/Factorial.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : int => unit = "print"; 2 | 3 | /* Based on https://rosettacode.org/wiki/Factorial#Recursive_50 */ 4 | let rec factorial = (n) => 5 | n <= 0 6 | ? 1 7 | : n * factorial(n - 1); 8 | 9 | print(factorial(6)); 10 | -------------------------------------------------------------------------------- /examples/fizzbuzz/Fizzbuzz.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | /* Based on https://rosettacode.org/wiki/FizzBuzz#OCaml */ 4 | let fizzbuzz = (i) => 5 | switch (i mod 3, i mod 5) { 6 | | (0, 0) => "FizzBuzz" 7 | | (0, _) => "Fizz" 8 | | (_, 0) => "Buzz" 9 | | _ => string_of_int(i) 10 | }; 11 | 12 | for (i in 1 to 100) { 13 | print(fizzbuzz(i)) 14 | }; 15 | -------------------------------------------------------------------------------- /examples/greatest-common-divisor/GCD.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : int => unit = "print"; 2 | 3 | /* Based on https://rosettacode.org/wiki/Greatest_common_divisor#OCaml */ 4 | let rec gcd = (a, b) => 5 | switch (a mod b) { 6 | | 0 => b 7 | | r => gcd(b, r) 8 | }; 9 | 10 | print(gcd(27, 9)); 11 | -------------------------------------------------------------------------------- /examples/json/Json.re: -------------------------------------------------------------------------------- 1 | /* TODO: This ***sometimes*** crashes and I don't know why (something about malloc) */ 2 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 3 | 4 | open Belt; 5 | 6 | [@bs.deriving abstract] 7 | type fullName = { 8 | first: string, 9 | last: string, 10 | }; 11 | 12 | [@bs.deriving abstract] 13 | type person = { 14 | name: fullName, 15 | age: int, 16 | }; 17 | 18 | let person1 = person(~name=fullName(~first="Ricky", ~last="Zhang"), ~age=10); 19 | 20 | /* encode person1, then decode it */ 21 | let json = 22 | person1 23 | |. Js.Json.stringifyAny 24 | |. Option.getExn 25 | |. Js.Json.parseExn; 26 | 27 | let name = 28 | json 29 | |. Js.Json.decodeObject 30 | |. Option.flatMap(p => Js.Dict.get(p, "name")) 31 | |. Option.flatMap(json => Js.Json.decodeObject(json)) 32 | |. Option.getExn; 33 | 34 | let firstName = 35 | Js.Dict.get(name, "first") 36 | |. Option.flatMap(json => Js.Json.decodeString(json)) 37 | |. Option.getExn; 38 | 39 | let lastName = 40 | Js.Dict.get(name, "last") 41 | |. Option.flatMap(json => Js.Json.decodeString(json)) 42 | |. Option.getExn; 43 | 44 | print({j|Hello, $firstName $lastName|j}); 45 | -------------------------------------------------------------------------------- /examples/mixed-deps/Index.ml: -------------------------------------------------------------------------------- 1 | external print : string -> unit = "print"[@@bs.scope "V8Worker2"][@@bs.val ] 2 | let student = 3 | [|{ Student.name = "Blaine" }; 4 | { Student.name = "Jake" }; 5 | { Student.name = "Nick" }|] 6 | let a = Belt.Array.map student (fun s -> s.name) 7 | let _ = Belt.Array.forEach a print 8 | -------------------------------------------------------------------------------- /examples/mixed-deps/Student.re: -------------------------------------------------------------------------------- 1 | type a = {name: string}; 2 | -------------------------------------------------------------------------------- /examples/mli/School.ml: -------------------------------------------------------------------------------- 1 | external print : string -> unit = "print"[@@bs.scope "V8Worker2"][@@bs.val ] 2 | type profession = 3 | | Teacher 4 | | Director 5 | let person1 = Teacher 6 | let getProfession person = 7 | match person with | Teacher -> "A teacher" | Director -> "A director" 8 | let _ = print (getProfession person1) 9 | -------------------------------------------------------------------------------- /examples/mli/School.mli: -------------------------------------------------------------------------------- 1 | type profession 2 | 3 | val getProfession : profession -> string 4 | -------------------------------------------------------------------------------- /examples/normal-random/NormalRandom.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : float => unit = "print"; 2 | 3 | /* Based on https://rosettacode.org/wiki/Random_numbers#OCaml */ 4 | let pi = 4. *. atan(1.); 5 | 6 | let random_gaussian = () => 7 | 1. +. sqrt((-2.) *. log(Random.float(1.))) *. cos(2. *. pi *. Random.float(1.)); 8 | 9 | Belt.Array.makeBy(42, (_) => random_gaussian()) |. Belt.Array.forEach(print); 10 | -------------------------------------------------------------------------------- /examples/ocaml-fizzbuzz/Fizzbuzz.ml: -------------------------------------------------------------------------------- 1 | external print : string -> unit = "print"[@@bs.scope "V8Worker2"][@@bs.val ] 2 | let fizzbuzz i = 3 | match ((i mod 3), (i mod 5)) with 4 | | (0,0) -> "FizzBuzz" 5 | | (0,_) -> "Fizz" 6 | | (_,0) -> "Buzz" 7 | | _ -> string_of_int i 8 | let _ = for i = 1 to 100 do print (fizzbuzz i) done 9 | -------------------------------------------------------------------------------- /examples/regexp/Regexp.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | let input = {| 4 | 5 |
6 |This is a very simple HTML document
10 |It only has two paragraphs
11 | 12 | 13 | |}; 14 | 15 | let result = Js.String.match([%re {|/(.*?)<\/p>/gi|}], input); 16 | 17 | switch (result) { 18 | | Some(result) => Js.Array.forEach(print, result) 19 | | None => print("no matches") 20 | }; 21 | -------------------------------------------------------------------------------- /examples/rei/School.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | type profession = Teacher | Director; 4 | 5 | let person1 = Teacher; 6 | let getProfession = (person) => 7 | switch (person) { 8 | | Teacher => "A teacher" 9 | | Director => "A director" 10 | }; 11 | 12 | print(getProfession(person1)); 13 | -------------------------------------------------------------------------------- /examples/rei/School.rei: -------------------------------------------------------------------------------- 1 | type profession; 2 | 3 | let getProfession: profession => string; 4 | -------------------------------------------------------------------------------- /examples/shebang/Shebang.re: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env reasonable 2 | 3 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 4 | 5 | print("Hello Executable!") 6 | -------------------------------------------------------------------------------- /examples/string-interpolation/StringInterpolation.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | for (a in 1 to 10) { 4 | for (b in 1 to 10) { 5 | let product = a * b; 6 | print({j|🐙 $a times $b is $product|j}) 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /examples/towers-of-hanoi/Towers.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : string => unit = "print"; 2 | 3 | /* Based on https://rosettacode.org/wiki/Towers_of_Hanoi#OCaml */ 4 | let rec hanoi = (n, a, b, c) => 5 | if (n > 0) { 6 | hanoi(n - 1, a, c, b); 7 | print({j|Move disk from pole $a to pole $b|j}); 8 | hanoi(n - 1, c, b, a) 9 | }; 10 | 11 | hanoi(4, 1, 2, 3); 12 | -------------------------------------------------------------------------------- /examples/tree-sum/TreeSum.re: -------------------------------------------------------------------------------- 1 | [@bs.scope "V8Worker2"] [@bs.val] external print : int => unit = "print"; 2 | 3 | type tree = Leaf | Node(int, tree, tree); 4 | 5 | let rec sum = (item) => { 6 | switch (item) { 7 | | Leaf => 0 8 | | Node(value, left, right) => value + sum(left) + sum(right); 9 | } 10 | }; 11 | 12 | let myTree = 13 | Node( 14 | 1, 15 | Node(2, Node(4, Leaf, Leaf), Node(6, Leaf, Leaf)), 16 | Node(3, Node(5, Leaf, Leaf), Node(7, Leaf, Leaf)) 17 | ); 18 | 19 | print(sum(myTree)); 20 | -------------------------------------------------------------------------------- /generate.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "log" 7 | "net/http" 8 | 9 | "github.com/shurcooL/vfsgen" 10 | ) 11 | 12 | func main() { 13 | var fs http.FileSystem = http.Dir("runtime") 14 | 15 | err := vfsgen.Generate(fs, vfsgen.Options{ 16 | Filename: "runtime/static_contents.go", 17 | PackageName: "runtime", 18 | VariableName: "Assets", 19 | }) 20 | if err != nil { 21 | log.Fatalln(err) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | //go:generate go run generate.go 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "io/ioutil" 8 | "log" 9 | "os" 10 | "path/filepath" 11 | "strings" 12 | 13 | flatbuffers "github.com/google/flatbuffers/go" 14 | "github.com/phated/reasonable/message" 15 | "github.com/phated/reasonable/module" 16 | "github.com/phated/reasonable/runtime" 17 | "github.com/ry/v8worker2" 18 | ) 19 | 20 | func OpenAsset(filename string) (string, error) { 21 | file, fileErr := runtime.Assets.Open(filename) 22 | if fileErr != nil { 23 | return "", fileErr 24 | } 25 | 26 | contents, contentsErr := ioutil.ReadAll(file) 27 | if contentsErr != nil { 28 | return "", contentsErr 29 | } 30 | 31 | return string(contents), nil 32 | } 33 | 34 | func LoadModuleByFilename(worker *v8worker2.Worker, filename string, resolve v8worker2.ModuleResolverCallback) error { 35 | module, moduleErr := OpenAsset(filename) 36 | if moduleErr != nil { 37 | return moduleErr 38 | } 39 | 40 | return worker.LoadModule(filename, module, resolve) 41 | } 42 | 43 | func CompileCode(worker *v8worker2.Worker) error { 44 | builder := flatbuffers.NewBuilder(0) 45 | message.MessageStart(builder) 46 | message.MessageAddType(builder, message.MessageTypeCompile) 47 | msg := message.MessageEnd(builder) 48 | builder.Finish(msg) 49 | out := builder.FinishedBytes() 50 | return worker.SendBytes(out) 51 | } 52 | 53 | func RegisterModule(worker *v8worker2.Worker, mod module.Module) error { 54 | builder := flatbuffers.NewBuilder(0) 55 | name := builder.CreateString(mod.GetIdentifier()) 56 | data := builder.CreateByteString(mod.GetContents()) 57 | message.MessageStart(builder) 58 | message.MessageAddType(builder, message.MessageTypeRegisterModule) 59 | message.MessageAddFileType(builder, mod.GetFileType()) 60 | message.MessageAddName(builder, name) 61 | message.MessageAddData(builder, data) 62 | msg := message.MessageEnd(builder) 63 | builder.Finish(msg) 64 | out := builder.FinishedBytes() 65 | return worker.SendBytes(out) 66 | } 67 | 68 | // This can be used when you know there are no deps and you want it to fail. 69 | func failModuleResolver(_, _ string) int { 70 | return 1 71 | } 72 | 73 | func main() { 74 | if len(os.Args) == 1 { 75 | log.Println("Need a Reason script to run. Try `reasonable *.re`") 76 | return 77 | } 78 | 79 | paths := os.Args[1:] 80 | searchPaths := []string{} 81 | 82 | var resolveModule v8worker2.ModuleResolverCallback 83 | var worker *v8worker2.Worker 84 | 85 | findModule := func(moduleName string) (string, error) { 86 | for _, path := range searchPaths { 87 | module, moduleErr := ioutil.ReadFile(filepath.Join(path, moduleName)) 88 | if moduleErr != nil { 89 | continue 90 | } 91 | 92 | return string(module), nil 93 | } 94 | 95 | return "", fmt.Errorf("Unable to find module: %s", moduleName) 96 | } 97 | 98 | resolveModule = func(moduleName, referrerName string) int { 99 | if strings.HasPrefix(moduleName, "stdlib/") == true { 100 | module, moduleErr := OpenAsset(moduleName) 101 | if moduleErr != nil { 102 | return 1 103 | } 104 | 105 | if err := worker.LoadModule(moduleName, module, resolveModule); err != nil { 106 | return 1 107 | } 108 | 109 | return 0 110 | } 111 | 112 | module, moduleErr := findModule(moduleName) 113 | if moduleErr != nil { 114 | return 1 115 | } 116 | 117 | if err := worker.LoadModule(moduleName, module, resolveModule); err != nil { 118 | return 1 119 | } 120 | 121 | return 0 122 | } 123 | 124 | worker = v8worker2.New(func(data []byte) []byte { 125 | if worker == nil { 126 | return nil 127 | } 128 | 129 | msg := message.GetRootAsMessage(data, 0) 130 | msgType := msg.Type() 131 | code := msg.Data() 132 | 133 | switch msgType { 134 | case message.MessageTypeRun: 135 | err := worker.LoadModule("main.js", string(code), resolveModule) 136 | if err != nil { 137 | log.Println(err) 138 | return nil 139 | } 140 | default: 141 | log.Println("Unknown message type:", msgType) 142 | } 143 | 144 | return nil 145 | }) 146 | 147 | // BuckleScript compiler and Refmt 148 | if err := LoadModuleByFilename(worker, "compiler.js", failModuleResolver); err != nil { 149 | log.Println(err) 150 | return 151 | } 152 | if err := LoadModuleByFilename(worker, "refmt.js", failModuleResolver); err != nil { 153 | log.Println(err) 154 | return 155 | } 156 | 157 | // FlatBuffer stuff 158 | if err := LoadModuleByFilename(worker, "flatbuffers.js", failModuleResolver); err != nil { 159 | log.Println(err) 160 | return 161 | } 162 | if err := LoadModuleByFilename(worker, "messages_generated.js", failModuleResolver); err != nil { 163 | log.Println(err) 164 | return 165 | } 166 | 167 | if err := LoadModuleByFilename(worker, "utils.js", failModuleResolver); err != nil { 168 | log.Println(err) 169 | return 170 | } 171 | 172 | if err := LoadModuleByFilename(worker, "topo.js", failModuleResolver); err != nil { 173 | log.Println(err) 174 | return 175 | } 176 | 177 | if err := LoadModuleByFilename(worker, "run.js", resolveModule); err != nil { 178 | log.Println(err) 179 | return 180 | } 181 | 182 | if len(paths) == 1 { 183 | path := paths[0] 184 | 185 | info, err := os.Stat(path) 186 | if err != nil { 187 | log.Println(err) 188 | return 189 | } 190 | 191 | if info.IsDir() == true { 192 | reMatches, reErr := filepath.Glob(filepath.Join(path, "*.re")) 193 | 194 | if reErr != nil { 195 | log.Println(reErr) 196 | return 197 | } 198 | 199 | mlMatches, mlErr := filepath.Glob(filepath.Join(path, "*.ml")) 200 | if mlErr != nil { 201 | log.Println(mlErr) 202 | return 203 | } 204 | 205 | paths = append(reMatches, mlMatches...) 206 | } 207 | } 208 | 209 | for _, path := range paths { 210 | absPath, absErr := filepath.Abs(path) 211 | if absErr != nil { 212 | log.Println(absErr) 213 | return 214 | } 215 | 216 | searchPaths = append(searchPaths, filepath.Dir(absPath)) 217 | 218 | mod := module.NewFromFilepath(path) 219 | if err := mod.Load(); err != nil { 220 | log.Println(err) 221 | return 222 | } 223 | 224 | RegisterModule(worker, mod) 225 | } 226 | 227 | if err := CompileCode(worker); err != nil { 228 | log.Println(err) 229 | return 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /message/FileType.go: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package message 4 | 5 | const ( 6 | FileTypeReason = 0 7 | FileTypeOCaml = 1 8 | ) 9 | 10 | var EnumNamesFileType = map[int]string{ 11 | FileTypeReason:"Reason", 12 | FileTypeOCaml:"OCaml", 13 | } 14 | 15 | -------------------------------------------------------------------------------- /message/Message.go: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package message 4 | 5 | import ( 6 | flatbuffers "github.com/google/flatbuffers/go" 7 | ) 8 | 9 | type Message struct { 10 | _tab flatbuffers.Table 11 | } 12 | 13 | func GetRootAsMessage(buf []byte, offset flatbuffers.UOffsetT) *Message { 14 | n := flatbuffers.GetUOffsetT(buf[offset:]) 15 | x := &Message{} 16 | x.Init(buf, n+offset) 17 | return x 18 | } 19 | 20 | func (rcv *Message) Init(buf []byte, i flatbuffers.UOffsetT) { 21 | rcv._tab.Bytes = buf 22 | rcv._tab.Pos = i 23 | } 24 | 25 | func (rcv *Message) Table() flatbuffers.Table { 26 | return rcv._tab 27 | } 28 | 29 | func (rcv *Message) Type() int8 { 30 | o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 31 | if o != 0 { 32 | return rcv._tab.GetInt8(o + rcv._tab.Pos) 33 | } 34 | return 0 35 | } 36 | 37 | func (rcv *Message) MutateType(n int8) bool { 38 | return rcv._tab.MutateInt8Slot(4, n) 39 | } 40 | 41 | func (rcv *Message) FileType() int8 { 42 | o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 43 | if o != 0 { 44 | return rcv._tab.GetInt8(o + rcv._tab.Pos) 45 | } 46 | return 0 47 | } 48 | 49 | func (rcv *Message) MutateFileType(n int8) bool { 50 | return rcv._tab.MutateInt8Slot(6, n) 51 | } 52 | 53 | func (rcv *Message) Name() []byte { 54 | o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 55 | if o != 0 { 56 | return rcv._tab.ByteVector(o + rcv._tab.Pos) 57 | } 58 | return nil 59 | } 60 | 61 | func (rcv *Message) Data() []byte { 62 | o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) 63 | if o != 0 { 64 | return rcv._tab.ByteVector(o + rcv._tab.Pos) 65 | } 66 | return nil 67 | } 68 | 69 | func MessageStart(builder *flatbuffers.Builder) { 70 | builder.StartObject(4) 71 | } 72 | func MessageAddType(builder *flatbuffers.Builder, type_ int8) { 73 | builder.PrependInt8Slot(0, type_, 0) 74 | } 75 | func MessageAddFileType(builder *flatbuffers.Builder, fileType int8) { 76 | builder.PrependInt8Slot(1, fileType, 0) 77 | } 78 | func MessageAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { 79 | builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(name), 0) 80 | } 81 | func MessageAddData(builder *flatbuffers.Builder, data flatbuffers.UOffsetT) { 82 | builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(data), 0) 83 | } 84 | func MessageEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 85 | return builder.EndObject() 86 | } 87 | -------------------------------------------------------------------------------- /message/MessageType.go: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | package message 4 | 5 | const ( 6 | MessageTypeCompile = 0 7 | MessageTypeRun = 1 8 | MessageTypeRegisterModule = 2 9 | ) 10 | 11 | var EnumNamesMessageType = map[int]string{ 12 | MessageTypeCompile:"Compile", 13 | MessageTypeRun:"Run", 14 | MessageTypeRegisterModule:"RegisterModule", 15 | } 16 | 17 | -------------------------------------------------------------------------------- /messages.fbs: -------------------------------------------------------------------------------- 1 | namespace message; 2 | 3 | enum MessageType : byte { 4 | Compile = 0, 5 | Run, 6 | RegisterModule 7 | } 8 | 9 | enum FileType : byte { 10 | Reason = 0, 11 | OCaml 12 | } 13 | 14 | table Message { 15 | type:MessageType; 16 | fileType:FileType; 17 | name:string; 18 | data:string; 19 | } 20 | 21 | root_type Message; 22 | -------------------------------------------------------------------------------- /module/module.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io/ioutil" 7 | "path/filepath" 8 | "strings" 9 | 10 | "github.com/phated/reasonable/message" 11 | ) 12 | 13 | type Module struct { 14 | fileType int8 15 | identifier string 16 | interfacePath *string 17 | interfaceContents []byte 18 | sourcePath *string 19 | sourceContents []byte 20 | modifiedContents string 21 | compiledContents *string 22 | } 23 | 24 | func NewFromFilepath(sourcePath string) Module { 25 | _, filename := filepath.Split(sourcePath) 26 | ext := filepath.Ext(sourcePath) 27 | var fileType int8 28 | var interfacePath string 29 | 30 | identifier := strings.Title(strings.TrimSuffix(filename, ext)) 31 | 32 | switch ext { 33 | case ".re": 34 | fileType = message.FileTypeReason 35 | interfacePath = sourcePath + "i" 36 | case ".ml": 37 | fileType = message.FileTypeOCaml 38 | interfacePath = sourcePath + "i" 39 | } 40 | 41 | return Module{ 42 | fileType: fileType, 43 | identifier: identifier, 44 | sourcePath: &sourcePath, 45 | interfacePath: &interfacePath, 46 | } 47 | } 48 | 49 | func (m *Module) GetIdentifier() string { 50 | return m.identifier 51 | } 52 | 53 | func (m *Module) Load() error { 54 | if err := m.LoadInterface(); err != nil { 55 | return err 56 | } 57 | 58 | if err := m.LoadSource(); err != nil { 59 | return err 60 | } 61 | 62 | m.CommentShebang() 63 | m.WrapContents() 64 | 65 | return nil 66 | } 67 | 68 | func (m *Module) LoadSource() error { 69 | if contents, err := ioutil.ReadFile(*m.sourcePath); err != nil { 70 | return err 71 | } else { 72 | m.sourceContents = contents 73 | } 74 | 75 | return nil 76 | } 77 | 78 | func (m *Module) LoadInterface() error { 79 | if m.interfacePath == nil { 80 | return nil 81 | } 82 | 83 | if contents, err := ioutil.ReadFile(*m.interfacePath); err != nil { 84 | // Ignore failure to load interface 85 | m.interfacePath = nil 86 | } else { 87 | m.interfaceContents = contents 88 | } 89 | 90 | return nil 91 | } 92 | 93 | func (m *Module) CommentShebang() { 94 | // We comment the shebang to keep line numbers the same 95 | // TODO: Use // comment when refmt ships it 96 | // TODO: Update to comment correctly for ocaml/JS files 97 | if m.sourceContents[0] == '#' && 98 | m.sourceContents[1] == '!' { 99 | beginComment := bytes.Replace(m.sourceContents, []byte("#!"), []byte("/*#!"), 1) 100 | endComment := bytes.Replace(beginComment, []byte("\n"), []byte("*/\n"), 1) 101 | m.sourceContents = endComment 102 | } 103 | } 104 | 105 | func (m *Module) WrapContents() { 106 | if m.sourceContents == nil { 107 | return 108 | } 109 | 110 | if m.fileType == message.FileTypeReason { 111 | if m.interfaceContents != nil { 112 | moduleWrapper := `module %s: { %s } = { %s }` 113 | m.modifiedContents = fmt.Sprintf(moduleWrapper, m.identifier, m.interfaceContents, m.sourceContents) 114 | } else { 115 | moduleWrapper := `module %s = { %s };` 116 | m.modifiedContents = fmt.Sprintf(moduleWrapper, m.identifier, m.sourceContents) 117 | } 118 | } 119 | 120 | if m.fileType == message.FileTypeOCaml { 121 | if m.interfaceContents != nil { 122 | moduleWrapper := `module %s : sig %s end = struct %s end` 123 | m.modifiedContents = fmt.Sprintf(moduleWrapper, m.identifier, m.interfaceContents, m.sourceContents) 124 | } else { 125 | moduleWrapper := `module %s = struct %s end` 126 | m.modifiedContents = fmt.Sprintf(moduleWrapper, m.identifier, m.sourceContents) 127 | } 128 | } 129 | } 130 | 131 | func (m *Module) GetContents() []byte { 132 | return []byte(m.modifiedContents) 133 | } 134 | 135 | func (m *Module) GetFileType() int8 { 136 | return m.fileType 137 | } 138 | -------------------------------------------------------------------------------- /reasonable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phated/reasonable/99780e79f120c6c68604e63ed6667cad814ccbf4/reasonable -------------------------------------------------------------------------------- /runtime/messages_generated.js: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /** 4 | * @const 5 | * @namespace 6 | */ 7 | var message = message || {}; 8 | 9 | /** 10 | * @enum 11 | */ 12 | message.MessageType = { 13 | Compile: 0, 14 | Run: 1, 15 | RegisterModule: 2 16 | }; 17 | 18 | /** 19 | * @enum 20 | */ 21 | message.FileType = { 22 | Reason: 0, 23 | OCaml: 1 24 | }; 25 | 26 | /** 27 | * @constructor 28 | */ 29 | message.Message = function() { 30 | /** 31 | * @type {flatbuffers.ByteBuffer} 32 | */ 33 | this.bb = null; 34 | 35 | /** 36 | * @type {number} 37 | */ 38 | this.bb_pos = 0; 39 | }; 40 | 41 | /** 42 | * @param {number} i 43 | * @param {flatbuffers.ByteBuffer} bb 44 | * @returns {message.Message} 45 | */ 46 | message.Message.prototype.__init = function(i, bb) { 47 | this.bb_pos = i; 48 | this.bb = bb; 49 | return this; 50 | }; 51 | 52 | /** 53 | * @param {flatbuffers.ByteBuffer} bb 54 | * @param {message.Message=} obj 55 | * @returns {message.Message} 56 | */ 57 | message.Message.getRootAsMessage = function(bb, obj) { 58 | return (obj || new message.Message).__init(bb.readInt32(bb.position()) + bb.position(), bb); 59 | }; 60 | 61 | /** 62 | * @returns {message.MessageType} 63 | */ 64 | message.Message.prototype.type = function() { 65 | var offset = this.bb.__offset(this.bb_pos, 4); 66 | return offset ? /** @type {message.MessageType} */ (this.bb.readInt8(this.bb_pos + offset)) : message.MessageType.Compile; 67 | }; 68 | 69 | /** 70 | * @returns {message.FileType} 71 | */ 72 | message.Message.prototype.fileType = function() { 73 | var offset = this.bb.__offset(this.bb_pos, 6); 74 | return offset ? /** @type {message.FileType} */ (this.bb.readInt8(this.bb_pos + offset)) : message.FileType.Reason; 75 | }; 76 | 77 | /** 78 | * @param {flatbuffers.Encoding=} optionalEncoding 79 | * @returns {string|Uint8Array|null} 80 | */ 81 | message.Message.prototype.name = function(optionalEncoding) { 82 | var offset = this.bb.__offset(this.bb_pos, 8); 83 | return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; 84 | }; 85 | 86 | /** 87 | * @param {flatbuffers.Encoding=} optionalEncoding 88 | * @returns {string|Uint8Array|null} 89 | */ 90 | message.Message.prototype.data = function(optionalEncoding) { 91 | var offset = this.bb.__offset(this.bb_pos, 10); 92 | return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; 93 | }; 94 | 95 | /** 96 | * @param {flatbuffers.Builder} builder 97 | */ 98 | message.Message.startMessage = function(builder) { 99 | builder.startObject(4); 100 | }; 101 | 102 | /** 103 | * @param {flatbuffers.Builder} builder 104 | * @param {message.MessageType} type 105 | */ 106 | message.Message.addType = function(builder, type) { 107 | builder.addFieldInt8(0, type, message.MessageType.Compile); 108 | }; 109 | 110 | /** 111 | * @param {flatbuffers.Builder} builder 112 | * @param {message.FileType} fileType 113 | */ 114 | message.Message.addFileType = function(builder, fileType) { 115 | builder.addFieldInt8(1, fileType, message.FileType.Reason); 116 | }; 117 | 118 | /** 119 | * @param {flatbuffers.Builder} builder 120 | * @param {flatbuffers.Offset} nameOffset 121 | */ 122 | message.Message.addName = function(builder, nameOffset) { 123 | builder.addFieldOffset(2, nameOffset, 0); 124 | }; 125 | 126 | /** 127 | * @param {flatbuffers.Builder} builder 128 | * @param {flatbuffers.Offset} dataOffset 129 | */ 130 | message.Message.addData = function(builder, dataOffset) { 131 | builder.addFieldOffset(3, dataOffset, 0); 132 | }; 133 | 134 | /** 135 | * @param {flatbuffers.Builder} builder 136 | * @returns {flatbuffers.Offset} 137 | */ 138 | message.Message.endMessage = function(builder) { 139 | var offset = builder.endObject(); 140 | return offset; 141 | }; 142 | 143 | /** 144 | * @param {flatbuffers.Builder} builder 145 | * @param {flatbuffers.Offset} offset 146 | */ 147 | message.Message.finishMessageBuffer = function(builder, offset) { 148 | builder.finish(offset); 149 | }; 150 | 151 | // Exports for ECMAScript6 Modules 152 | export {message}; 153 | -------------------------------------------------------------------------------- /runtime/run.js: -------------------------------------------------------------------------------- 1 | import { typedArrayToArrayBuffer } from 'utils.js'; 2 | import { flatbuffers } from 'flatbuffers.js'; 3 | import { message } from 'messages_generated.js'; 4 | import { Topo } from 'topo.js'; 5 | import { compiler } from 'compiler.js'; 6 | import { refmt } from 'refmt.js'; 7 | 8 | const { MessageType, Message, FileType } = message; 9 | 10 | const modules = new Map(); 11 | const dependencies = new Topo(); 12 | 13 | function getCompiler() { 14 | // These are the non-Node things that the BuckleScript compiler looks for on global 15 | const global = { 16 | // Binary 17 | Float32Array, 18 | Float64Array, 19 | Int8Array, 20 | Uint8Array, 21 | Int16Array, 22 | Uint16Array, 23 | Int32Array, 24 | // Errors 25 | RangeError, 26 | // `InternalError` doesn't exist in V8 27 | Error, 28 | // JSON 29 | JSON, 30 | // TODO: Console 31 | }; 32 | compiler(global); 33 | return global.ocaml; 34 | } 35 | 36 | function runCode(code) { 37 | const builder = new flatbuffers.Builder(0); 38 | const name = builder.createString("main.js"); 39 | const data = builder.createString(code); 40 | Message.startMessage(builder); 41 | Message.addType(builder, MessageType.Run); 42 | Message.addName(builder, name); 43 | Message.addData(builder, data); 44 | const msg = Message.endMessage(builder); 45 | builder.finish(msg); 46 | const ta = builder.asUint8Array(); 47 | V8Worker2.send(typedArrayToArrayBuffer(ta)); 48 | } 49 | 50 | function registerModule(name, fileType, code) { 51 | let ocamlCode = ''; 52 | if (fileType === FileType.Reason) { 53 | // Parse/Print here so we don't need to do a second pass upon compile 54 | ocamlCode = refmt.printML(refmt.parseRE(code)); 55 | } 56 | 57 | if (fileType === FileType.OCaml) { 58 | ocamlCode = code 59 | } 60 | 61 | const deps = parseDeps(ocamlCode); 62 | dependencies.add(name, { after: deps, group: name }); 63 | modules.set(name, ocamlCode); 64 | } 65 | 66 | function compileModules() { 67 | const compiler = getCompiler(); 68 | 69 | const ocamlCode = dependencies.nodes.reduce(function(outCode, moduleName) { 70 | const code = modules.get(moduleName); 71 | if (code) { 72 | // TODO: Is inserting this newline enough? 73 | return outCode + "\n" + code; 74 | } else { 75 | return outCode; 76 | } 77 | }, ""); 78 | 79 | const res = compiler.compile_super_errors(ocamlCode); 80 | 81 | if (res.js_code) { 82 | // V8Worker2.print(res.js_code); 83 | runCode(res.js_code); 84 | } else { 85 | V8Worker2.print(res.js_error_msg); 86 | } 87 | } 88 | 89 | function parseDeps(ocamlCode) { 90 | const compiler = getCompiler(); 91 | 92 | const deps = compiler.list_dependencies(ocamlCode); 93 | const trimmed = deps.slice(1); 94 | 95 | if (trimmed.length != 0) { 96 | return trimmed; 97 | } 98 | 99 | return []; 100 | } 101 | 102 | V8Worker2.recv(function(bytes) { 103 | const buf = new flatbuffers.ByteBuffer(new Uint8Array(bytes)); 104 | const msg = Message.getRootAsMessage(buf); 105 | const msgType = msg.type(); 106 | 107 | switch (msgType) { 108 | case MessageType.Compile: { 109 | return compileModules(); 110 | } 111 | case MessageType.RegisterModule: { 112 | const name = msg.name(); 113 | const fileType = msg.fileType(); 114 | const code = msg.data(); 115 | return registerModule(name, fileType, code); 116 | } 117 | default: { 118 | V8Worker2.print(`Unknown msg type`); 119 | } 120 | } 121 | }); 122 | -------------------------------------------------------------------------------- /runtime/stdlib/arrayLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as $$Array from "stdlib/array.js"; 4 | 5 | var init = $$Array.init; 6 | 7 | var make_matrix = $$Array.make_matrix; 8 | 9 | var create_matrix = $$Array.create_matrix; 10 | 11 | var append = $$Array.append; 12 | 13 | var concat = $$Array.concat; 14 | 15 | var sub = $$Array.sub; 16 | 17 | var copy = $$Array.copy; 18 | 19 | var fill = $$Array.fill; 20 | 21 | var blit = $$Array.blit; 22 | 23 | var to_list = $$Array.to_list; 24 | 25 | var of_list = $$Array.of_list; 26 | 27 | var iter = $$Array.iter; 28 | 29 | var map = $$Array.map; 30 | 31 | var iteri = $$Array.iteri; 32 | 33 | var mapi = $$Array.mapi; 34 | 35 | var fold_left = $$Array.fold_left; 36 | 37 | var fold_right = $$Array.fold_right; 38 | 39 | var sort = $$Array.sort; 40 | 41 | var stable_sort = $$Array.stable_sort; 42 | 43 | var fast_sort = $$Array.fast_sort; 44 | 45 | export { 46 | init , 47 | make_matrix , 48 | create_matrix , 49 | append , 50 | concat , 51 | sub , 52 | copy , 53 | fill , 54 | blit , 55 | to_list , 56 | of_list , 57 | iter , 58 | map , 59 | iteri , 60 | mapi , 61 | fold_left , 62 | fold_right , 63 | sort , 64 | stable_sort , 65 | fast_sort , 66 | 67 | } 68 | /* No side effect */ 69 | -------------------------------------------------------------------------------- /runtime/stdlib/belt.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var Id = 0; 5 | 6 | var $$Array = 0; 7 | 8 | var SortArray = 0; 9 | 10 | var MutableQueue = 0; 11 | 12 | var MutableStack = 0; 13 | 14 | var List = 0; 15 | 16 | var Range = 0; 17 | 18 | var $$Set = 0; 19 | 20 | var $$Map = 0; 21 | 22 | var MutableSet = 0; 23 | 24 | var MutableMap = 0; 25 | 26 | var HashSet = 0; 27 | 28 | var HashMap = 0; 29 | 30 | var Option = 0; 31 | 32 | var Result = 0; 33 | 34 | var Debug = 0; 35 | 36 | export { 37 | Id , 38 | $$Array , 39 | SortArray , 40 | MutableQueue , 41 | MutableStack , 42 | List , 43 | Range , 44 | $$Set , 45 | $$Map , 46 | MutableSet , 47 | MutableMap , 48 | HashSet , 49 | HashMap , 50 | Option , 51 | Result , 52 | Debug , 53 | 54 | } 55 | /* No side effect */ 56 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_Debug.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var setupChromeDebugger = function (unit){ 5 | // I don't know how to directly refer to the classes that chrome's built-in 6 | // formatters use. adding "class": "foo" doesn't seem to work 7 | // tree-outline 8 | var olStyle = {"style": "list-style-type: none; padding-left: 12px; margin: 0"} 9 | // object-properties-section-separator 10 | var colonStyle = {"style": "flex-shrink: 0; padding-right: 5px"} 11 | var recordNumberStyle = {"style": "flex-shrink: 0; padding-right: 5px; color: rgb(145, 145, 145)"} 12 | 13 | var recordCustomFormatter = function (data, labels) { 14 | return [ 15 | "ol", 16 | olStyle, 17 | ...data.map(function (cur, index) { 18 | return [ 19 | "li", 20 | {}, 21 | ["span", recordNumberStyle, index], 22 | ["span", {"style": "color: rgb(227, 110, 236)"}, labels[index]], 23 | ["span", colonStyle, ":"], 24 | ["span", {}, ["object", { "object": cur }]], 25 | ] 26 | }) 27 | ] 28 | }; 29 | 30 | var listToArray = function (data){ 31 | var result = [] 32 | var cur = data 33 | var index = 0 34 | while(typeof cur !== "number"){ 35 | result.push([ 36 | "li", 37 | {}, 38 | ["span", {"style": "color: rgb(227, 110, 236)"}, index], 39 | ["span", colonStyle, ":"], 40 | ["object", {"object": cur[0]}] 41 | ]); 42 | cur = cur[1] 43 | index++ 44 | } 45 | return result 46 | }; 47 | 48 | var variantCustomFormatter = function (data,recordVariant){ 49 | if(recordVariant === "::"){ 50 | return [ 51 | "ol", 52 | olStyle, 53 | ... listToArray(data) 54 | ] 55 | } else { 56 | return ["ol", olStyle, ...data.map(function (cur) { return ["object", { "object": cur }] })] 57 | } 58 | 59 | }; 60 | 61 | var recordPreview = function (recordLabels){ 62 | var recordLastIndex = recordLabels.length - 1 63 | var preview = recordLabels.reduce(function (acc, cur, index) { 64 | if (index === recordLastIndex) { 65 | return acc + cur + "}" 66 | } 67 | return acc + cur + ", " 68 | }, "record {") 69 | return preview 70 | }; 71 | 72 | var variantPreview = function (x, recordVariant){ 73 | if(recordVariant === "::") { 74 | // show the length, just like for array 75 | var length = listToArray(x).length; 76 | return ['span', {}, `list(${length})`] 77 | } 78 | return ['span', {}, `${recordVariant}(…)`] 79 | }; 80 | var isOCamlExceptionOrExtensionHead = function(x){ 81 | return Array.isArray(x) && x.tag === 248 && typeof x[0] === "string" 82 | } 83 | var isOCamlExceptionOrExtension = function(x){ 84 | return Array.isArray(x) && 85 | x[0] !== undefined && 86 | isOCamlExceptionOrExtensionHead(x[0]) 87 | } 88 | var formatter = { 89 | header: function (x) { 90 | var recordLabels 91 | var recordVariant 92 | var recordModule 93 | var recordPolyVar 94 | if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { 95 | return ['div', {}, recordPreview(recordLabels)] 96 | } else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined){ 97 | return variantPreview(x, recordVariant) 98 | } else if (isOCamlExceptionOrExtension(x)){ 99 | return ['div',{}, `${x[0][0]}(…)`] 100 | } else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined){ 101 | return ['div', {}, 'Module' ] 102 | } else if ((recordPolyVar = x[Symbol.for('BsPolyVar')] ) !== undefined){ 103 | return ['div', {}, `\`${recordPolyVar}#${x[0]}`] 104 | } 105 | return null 106 | }, 107 | hasBody: function (x) { 108 | var recordLabels 109 | var recordVariant 110 | var recordModule 111 | var recordPolyVar 112 | if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { 113 | return true 114 | } else if ((recordVariant = x[Symbol.for('BsVariant')] ) !== undefined){ 115 | return recordVariant 116 | } else if(isOCamlExceptionOrExtension(x)){ 117 | return true 118 | } else if ((recordModule = x[Symbol.for('BsLocalModule')] ) !== undefined){ 119 | return true 120 | } else if( (recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined){ 121 | return true 122 | } 123 | return false 124 | }, 125 | body: function (x) { 126 | var recordLabels 127 | var recordVariant 128 | var recordModule 129 | var recordPolyVar 130 | if ( (recordLabels = x[Symbol.for('BsRecord')]) !== undefined 131 | ) { 132 | return recordCustomFormatter(x, recordLabels) 133 | } 134 | else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined){ 135 | return recordCustomFormatter(x, recordModule) 136 | } 137 | else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { 138 | return variantCustomFormatter(x,recordVariant) 139 | } 140 | else if ((recordPolyVar = x [Symbol.for('BsPolyVar')]) !== undefined){ 141 | return ["object", {"object" : x[1]}] 142 | } 143 | else if(isOCamlExceptionOrExtension(x)){ 144 | return ["ol", olStyle, ... x.slice(1).map(cur => ["object",{"object" : cur }])] 145 | } 146 | 147 | } 148 | 149 | } 150 | if (typeof window === "undefined"){ 151 | global.devtoolsFormatters = [formatter] 152 | } else { 153 | window.devtoolsFormatters = [formatter] 154 | } 155 | return 0 156 | 157 | }; 158 | 159 | export { 160 | setupChromeDebugger , 161 | 162 | } 163 | /* No side effect */ 164 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_HashSet.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Belt_internalSetBuckets from "stdlib/belt_internalSetBuckets.js"; 4 | import * as Belt_internalBucketsType from "stdlib/belt_internalBucketsType.js"; 5 | 6 | function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { 7 | while(true) { 8 | var old_bucket = _old_bucket; 9 | if (old_bucket !== undefined) { 10 | var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); 11 | var match = ndata_tail[nidx]; 12 | if (match !== undefined) { 13 | match.next = old_bucket; 14 | } else { 15 | h_buckets[nidx] = old_bucket; 16 | } 17 | ndata_tail[nidx] = old_bucket; 18 | _old_bucket = old_bucket.next; 19 | continue ; 20 | } else { 21 | return /* () */0; 22 | } 23 | }; 24 | } 25 | 26 | function remove(h, key) { 27 | var eq = h.eq; 28 | var h_buckets = h.buckets; 29 | var i = h.hash(key) & (h_buckets.length - 1 | 0); 30 | var l = h_buckets[i]; 31 | if (l !== undefined) { 32 | var next_cell = l.next; 33 | if (eq(l.key, key)) { 34 | h.size = h.size - 1 | 0; 35 | h_buckets[i] = next_cell; 36 | return /* () */0; 37 | } else if (next_cell !== undefined) { 38 | var eq$1 = eq; 39 | var h$1 = h; 40 | var key$1 = key; 41 | var _prec = l; 42 | var _cell = next_cell; 43 | while(true) { 44 | var cell = _cell; 45 | var prec = _prec; 46 | var cell_next = cell.next; 47 | if (eq$1(cell.key, key$1)) { 48 | prec.next = cell_next; 49 | h$1.size = h$1.size - 1 | 0; 50 | return /* () */0; 51 | } else if (cell_next !== undefined) { 52 | _cell = cell_next; 53 | _prec = cell; 54 | continue ; 55 | } else { 56 | return /* () */0; 57 | } 58 | }; 59 | } else { 60 | return /* () */0; 61 | } 62 | } else { 63 | return /* () */0; 64 | } 65 | } 66 | 67 | function addBucket(h, key, _cell, eq) { 68 | while(true) { 69 | var cell = _cell; 70 | if (eq(cell.key, key)) { 71 | return 0; 72 | } else { 73 | var n = cell.next; 74 | if (n !== undefined) { 75 | _cell = n; 76 | continue ; 77 | } else { 78 | h.size = h.size + 1 | 0; 79 | cell.next = { 80 | key: key, 81 | next: Belt_internalBucketsType.emptyOpt 82 | }; 83 | return /* () */0; 84 | } 85 | } 86 | }; 87 | } 88 | 89 | function add0(h, key, hash, eq) { 90 | var h_buckets = h.buckets; 91 | var buckets_len = h_buckets.length; 92 | var i = hash(key) & (buckets_len - 1 | 0); 93 | var l = h_buckets[i]; 94 | if (l !== undefined) { 95 | addBucket(h, key, l, eq); 96 | } else { 97 | h.size = h.size + 1 | 0; 98 | h_buckets[i] = { 99 | key: key, 100 | next: Belt_internalBucketsType.emptyOpt 101 | }; 102 | } 103 | if (h.size > (buckets_len << 1)) { 104 | var hash$1 = hash; 105 | var h$1 = h; 106 | var odata = h$1.buckets; 107 | var osize = odata.length; 108 | var nsize = (osize << 1); 109 | if (nsize >= osize) { 110 | var h_buckets$1 = new Array(nsize); 111 | var ndata_tail = new Array(nsize); 112 | h$1.buckets = h_buckets$1; 113 | for(var i$1 = 0 ,i_finish = osize - 1 | 0; i$1 <= i_finish; ++i$1){ 114 | copyBucket(hash$1, h_buckets$1, ndata_tail, odata[i$1]); 115 | } 116 | for(var i$2 = 0 ,i_finish$1 = nsize - 1 | 0; i$2 <= i_finish$1; ++i$2){ 117 | var match = ndata_tail[i$2]; 118 | if (match !== undefined) { 119 | match.next = Belt_internalBucketsType.emptyOpt; 120 | } 121 | 122 | } 123 | return /* () */0; 124 | } else { 125 | return 0; 126 | } 127 | } else { 128 | return 0; 129 | } 130 | } 131 | 132 | function add(h, key) { 133 | return add0(h, key, h.hash, h.eq); 134 | } 135 | 136 | function has(h, key) { 137 | var eq = h.eq; 138 | var h_buckets = h.buckets; 139 | var nid = h.hash(key) & (h_buckets.length - 1 | 0); 140 | var bucket = h_buckets[nid]; 141 | if (bucket !== undefined) { 142 | var eq$1 = eq; 143 | var key$1 = key; 144 | var _cell = bucket; 145 | while(true) { 146 | var cell = _cell; 147 | if (eq$1(cell.key, key$1)) { 148 | return true; 149 | } else { 150 | var match = cell.next; 151 | if (match !== undefined) { 152 | _cell = match; 153 | continue ; 154 | } else { 155 | return false; 156 | } 157 | } 158 | }; 159 | } else { 160 | return false; 161 | } 162 | } 163 | 164 | function make(hintSize, id) { 165 | return Belt_internalBucketsType.make(id[/* hash */0], id[/* eq */1], hintSize); 166 | } 167 | 168 | function size(prim) { 169 | return prim.size; 170 | } 171 | 172 | function fromArray(arr, id) { 173 | var eq = id[/* eq */1]; 174 | var hash = id[/* hash */0]; 175 | var len = arr.length; 176 | var v = Belt_internalBucketsType.make(hash, eq, len); 177 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 178 | add0(v, arr[i], hash, eq); 179 | } 180 | return v; 181 | } 182 | 183 | function mergeMany(h, arr) { 184 | var eq = h.eq; 185 | var hash = h.hash; 186 | var len = arr.length; 187 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 188 | add0(h, arr[i], hash, eq); 189 | } 190 | return /* () */0; 191 | } 192 | 193 | var Int = 0; 194 | 195 | var $$String = 0; 196 | 197 | var clear = Belt_internalBucketsType.clear; 198 | 199 | var isEmpty = Belt_internalBucketsType.isEmpty; 200 | 201 | var copy = Belt_internalSetBuckets.copy; 202 | 203 | var forEachU = Belt_internalSetBuckets.forEachU; 204 | 205 | var forEach = Belt_internalSetBuckets.forEach; 206 | 207 | var reduceU = Belt_internalSetBuckets.reduceU; 208 | 209 | var reduce = Belt_internalSetBuckets.reduce; 210 | 211 | var logStats = Belt_internalSetBuckets.logStats; 212 | 213 | var toArray = Belt_internalSetBuckets.toArray; 214 | 215 | var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; 216 | 217 | export { 218 | Int , 219 | $$String , 220 | make , 221 | clear , 222 | isEmpty , 223 | add , 224 | copy , 225 | has , 226 | remove , 227 | forEachU , 228 | forEach , 229 | reduceU , 230 | reduce , 231 | size , 232 | logStats , 233 | toArray , 234 | fromArray , 235 | mergeMany , 236 | getBucketHistogram , 237 | 238 | } 239 | /* No side effect */ 240 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_HashSetInt.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_hash_primitive from "stdlib/caml_hash_primitive.js"; 4 | import * as Belt_internalSetBuckets from "stdlib/belt_internalSetBuckets.js"; 5 | import * as Belt_internalBucketsType from "stdlib/belt_internalBucketsType.js"; 6 | 7 | function copyBucket(h_buckets, ndata_tail, _old_bucket) { 8 | while(true) { 9 | var old_bucket = _old_bucket; 10 | if (old_bucket !== undefined) { 11 | var s = old_bucket.key; 12 | var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, s)) & (h_buckets.length - 1 | 0); 13 | var match = ndata_tail[nidx]; 14 | if (match !== undefined) { 15 | match.next = old_bucket; 16 | } else { 17 | h_buckets[nidx] = old_bucket; 18 | } 19 | ndata_tail[nidx] = old_bucket; 20 | _old_bucket = old_bucket.next; 21 | continue ; 22 | } else { 23 | return /* () */0; 24 | } 25 | }; 26 | } 27 | 28 | function remove(h, key) { 29 | var h_buckets = h.buckets; 30 | var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); 31 | var l = h_buckets[i]; 32 | if (l !== undefined) { 33 | var next_cell = l.next; 34 | if (l.key === key) { 35 | h.size = h.size - 1 | 0; 36 | h_buckets[i] = next_cell; 37 | return /* () */0; 38 | } else if (next_cell !== undefined) { 39 | var h$1 = h; 40 | var key$1 = key; 41 | var _prec = l; 42 | var _cell = next_cell; 43 | while(true) { 44 | var cell = _cell; 45 | var prec = _prec; 46 | var cell_next = cell.next; 47 | if (cell.key === key$1) { 48 | prec.next = cell_next; 49 | h$1.size = h$1.size - 1 | 0; 50 | return /* () */0; 51 | } else if (cell_next !== undefined) { 52 | _cell = cell_next; 53 | _prec = cell; 54 | continue ; 55 | } else { 56 | return /* () */0; 57 | } 58 | }; 59 | } else { 60 | return /* () */0; 61 | } 62 | } else { 63 | return /* () */0; 64 | } 65 | } 66 | 67 | function addBucket(h, key, _cell) { 68 | while(true) { 69 | var cell = _cell; 70 | if (cell.key !== key) { 71 | var n = cell.next; 72 | if (n !== undefined) { 73 | _cell = n; 74 | continue ; 75 | } else { 76 | h.size = h.size + 1 | 0; 77 | cell.next = { 78 | key: key, 79 | next: Belt_internalBucketsType.emptyOpt 80 | }; 81 | return /* () */0; 82 | } 83 | } else { 84 | return 0; 85 | } 86 | }; 87 | } 88 | 89 | function add(h, key) { 90 | var h_buckets = h.buckets; 91 | var buckets_len = h_buckets.length; 92 | var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (buckets_len - 1 | 0); 93 | var l = h_buckets[i]; 94 | if (l !== undefined) { 95 | addBucket(h, key, l); 96 | } else { 97 | h_buckets[i] = { 98 | key: key, 99 | next: Belt_internalBucketsType.emptyOpt 100 | }; 101 | h.size = h.size + 1 | 0; 102 | } 103 | if (h.size > (buckets_len << 1)) { 104 | var h$1 = h; 105 | var odata = h$1.buckets; 106 | var osize = odata.length; 107 | var nsize = (osize << 1); 108 | if (nsize >= osize) { 109 | var h_buckets$1 = new Array(nsize); 110 | var ndata_tail = new Array(nsize); 111 | h$1.buckets = h_buckets$1; 112 | for(var i$1 = 0 ,i_finish = osize - 1 | 0; i$1 <= i_finish; ++i$1){ 113 | copyBucket(h_buckets$1, ndata_tail, odata[i$1]); 114 | } 115 | for(var i$2 = 0 ,i_finish$1 = nsize - 1 | 0; i$2 <= i_finish$1; ++i$2){ 116 | var match = ndata_tail[i$2]; 117 | if (match !== undefined) { 118 | match.next = Belt_internalBucketsType.emptyOpt; 119 | } 120 | 121 | } 122 | return /* () */0; 123 | } else { 124 | return 0; 125 | } 126 | } else { 127 | return 0; 128 | } 129 | } 130 | 131 | function has(h, key) { 132 | var h_buckets = h.buckets; 133 | var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); 134 | var bucket = h_buckets[nid]; 135 | if (bucket !== undefined) { 136 | var key$1 = key; 137 | var _cell = bucket; 138 | while(true) { 139 | var cell = _cell; 140 | if (cell.key === key$1) { 141 | return true; 142 | } else { 143 | var match = cell.next; 144 | if (match !== undefined) { 145 | _cell = match; 146 | continue ; 147 | } else { 148 | return false; 149 | } 150 | } 151 | }; 152 | } else { 153 | return false; 154 | } 155 | } 156 | 157 | function make(hintSize) { 158 | return Belt_internalBucketsType.make(/* () */0, /* () */0, hintSize); 159 | } 160 | 161 | function size(prim) { 162 | return prim.size; 163 | } 164 | 165 | function fromArray(arr) { 166 | var len = arr.length; 167 | var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); 168 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 169 | add(v, arr[i]); 170 | } 171 | return v; 172 | } 173 | 174 | function mergeMany(h, arr) { 175 | var len = arr.length; 176 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 177 | add(h, arr[i]); 178 | } 179 | return /* () */0; 180 | } 181 | 182 | var clear = Belt_internalBucketsType.clear; 183 | 184 | var isEmpty = Belt_internalBucketsType.isEmpty; 185 | 186 | var copy = Belt_internalSetBuckets.copy; 187 | 188 | var forEachU = Belt_internalSetBuckets.forEachU; 189 | 190 | var forEach = Belt_internalSetBuckets.forEach; 191 | 192 | var reduceU = Belt_internalSetBuckets.reduceU; 193 | 194 | var reduce = Belt_internalSetBuckets.reduce; 195 | 196 | var logStats = Belt_internalSetBuckets.logStats; 197 | 198 | var toArray = Belt_internalSetBuckets.toArray; 199 | 200 | var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; 201 | 202 | export { 203 | make , 204 | clear , 205 | isEmpty , 206 | add , 207 | copy , 208 | has , 209 | remove , 210 | forEachU , 211 | forEach , 212 | reduceU , 213 | reduce , 214 | size , 215 | logStats , 216 | toArray , 217 | fromArray , 218 | mergeMany , 219 | getBucketHistogram , 220 | 221 | } 222 | /* No side effect */ 223 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_HashSetString.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_hash_primitive from "stdlib/caml_hash_primitive.js"; 4 | import * as Belt_internalSetBuckets from "stdlib/belt_internalSetBuckets.js"; 5 | import * as Belt_internalBucketsType from "stdlib/belt_internalBucketsType.js"; 6 | 7 | function copyBucket(h_buckets, ndata_tail, _old_bucket) { 8 | while(true) { 9 | var old_bucket = _old_bucket; 10 | if (old_bucket !== undefined) { 11 | var s = old_bucket.key; 12 | var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, s)) & (h_buckets.length - 1 | 0); 13 | var match = ndata_tail[nidx]; 14 | if (match !== undefined) { 15 | match.next = old_bucket; 16 | } else { 17 | h_buckets[nidx] = old_bucket; 18 | } 19 | ndata_tail[nidx] = old_bucket; 20 | _old_bucket = old_bucket.next; 21 | continue ; 22 | } else { 23 | return /* () */0; 24 | } 25 | }; 26 | } 27 | 28 | function remove(h, key) { 29 | var h_buckets = h.buckets; 30 | var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); 31 | var l = h_buckets[i]; 32 | if (l !== undefined) { 33 | var next_cell = l.next; 34 | if (l.key === key) { 35 | h.size = h.size - 1 | 0; 36 | h_buckets[i] = next_cell; 37 | return /* () */0; 38 | } else if (next_cell !== undefined) { 39 | var h$1 = h; 40 | var key$1 = key; 41 | var _prec = l; 42 | var _cell = next_cell; 43 | while(true) { 44 | var cell = _cell; 45 | var prec = _prec; 46 | var cell_next = cell.next; 47 | if (cell.key === key$1) { 48 | prec.next = cell_next; 49 | h$1.size = h$1.size - 1 | 0; 50 | return /* () */0; 51 | } else if (cell_next !== undefined) { 52 | _cell = cell_next; 53 | _prec = cell; 54 | continue ; 55 | } else { 56 | return /* () */0; 57 | } 58 | }; 59 | } else { 60 | return /* () */0; 61 | } 62 | } else { 63 | return /* () */0; 64 | } 65 | } 66 | 67 | function addBucket(h, key, _cell) { 68 | while(true) { 69 | var cell = _cell; 70 | if (cell.key !== key) { 71 | var n = cell.next; 72 | if (n !== undefined) { 73 | _cell = n; 74 | continue ; 75 | } else { 76 | h.size = h.size + 1 | 0; 77 | cell.next = { 78 | key: key, 79 | next: Belt_internalBucketsType.emptyOpt 80 | }; 81 | return /* () */0; 82 | } 83 | } else { 84 | return 0; 85 | } 86 | }; 87 | } 88 | 89 | function add(h, key) { 90 | var h_buckets = h.buckets; 91 | var buckets_len = h_buckets.length; 92 | var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (buckets_len - 1 | 0); 93 | var l = h_buckets[i]; 94 | if (l !== undefined) { 95 | addBucket(h, key, l); 96 | } else { 97 | h_buckets[i] = { 98 | key: key, 99 | next: Belt_internalBucketsType.emptyOpt 100 | }; 101 | h.size = h.size + 1 | 0; 102 | } 103 | if (h.size > (buckets_len << 1)) { 104 | var h$1 = h; 105 | var odata = h$1.buckets; 106 | var osize = odata.length; 107 | var nsize = (osize << 1); 108 | if (nsize >= osize) { 109 | var h_buckets$1 = new Array(nsize); 110 | var ndata_tail = new Array(nsize); 111 | h$1.buckets = h_buckets$1; 112 | for(var i$1 = 0 ,i_finish = osize - 1 | 0; i$1 <= i_finish; ++i$1){ 113 | copyBucket(h_buckets$1, ndata_tail, odata[i$1]); 114 | } 115 | for(var i$2 = 0 ,i_finish$1 = nsize - 1 | 0; i$2 <= i_finish$1; ++i$2){ 116 | var match = ndata_tail[i$2]; 117 | if (match !== undefined) { 118 | match.next = Belt_internalBucketsType.emptyOpt; 119 | } 120 | 121 | } 122 | return /* () */0; 123 | } else { 124 | return 0; 125 | } 126 | } else { 127 | return 0; 128 | } 129 | } 130 | 131 | function has(h, key) { 132 | var h_buckets = h.buckets; 133 | var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); 134 | var bucket = h_buckets[nid]; 135 | if (bucket !== undefined) { 136 | var key$1 = key; 137 | var _cell = bucket; 138 | while(true) { 139 | var cell = _cell; 140 | if (cell.key === key$1) { 141 | return true; 142 | } else { 143 | var match = cell.next; 144 | if (match !== undefined) { 145 | _cell = match; 146 | continue ; 147 | } else { 148 | return false; 149 | } 150 | } 151 | }; 152 | } else { 153 | return false; 154 | } 155 | } 156 | 157 | function make(hintSize) { 158 | return Belt_internalBucketsType.make(/* () */0, /* () */0, hintSize); 159 | } 160 | 161 | function size(prim) { 162 | return prim.size; 163 | } 164 | 165 | function fromArray(arr) { 166 | var len = arr.length; 167 | var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); 168 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 169 | add(v, arr[i]); 170 | } 171 | return v; 172 | } 173 | 174 | function mergeMany(h, arr) { 175 | var len = arr.length; 176 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 177 | add(h, arr[i]); 178 | } 179 | return /* () */0; 180 | } 181 | 182 | var clear = Belt_internalBucketsType.clear; 183 | 184 | var isEmpty = Belt_internalBucketsType.isEmpty; 185 | 186 | var copy = Belt_internalSetBuckets.copy; 187 | 188 | var forEachU = Belt_internalSetBuckets.forEachU; 189 | 190 | var forEach = Belt_internalSetBuckets.forEach; 191 | 192 | var reduceU = Belt_internalSetBuckets.reduceU; 193 | 194 | var reduce = Belt_internalSetBuckets.reduce; 195 | 196 | var logStats = Belt_internalSetBuckets.logStats; 197 | 198 | var toArray = Belt_internalSetBuckets.toArray; 199 | 200 | var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; 201 | 202 | export { 203 | make , 204 | clear , 205 | isEmpty , 206 | add , 207 | copy , 208 | has , 209 | remove , 210 | forEachU , 211 | forEach , 212 | reduceU , 213 | reduce , 214 | size , 215 | logStats , 216 | toArray , 217 | fromArray , 218 | mergeMany , 219 | getBucketHistogram , 220 | 221 | } 222 | /* No side effect */ 223 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_Id.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | 5 | function MakeComparableU(M) { 6 | var cmp = M[/* cmp */0]; 7 | return /* module */[/* cmp */cmp]; 8 | } 9 | 10 | function MakeComparable(M) { 11 | var cmp = M[/* cmp */0]; 12 | var cmp$1 = Curry.__2(cmp); 13 | return /* module */[/* cmp */cmp$1]; 14 | } 15 | 16 | function comparableU(cmp) { 17 | return /* module */[/* cmp */cmp]; 18 | } 19 | 20 | function comparable(cmp) { 21 | var cmp$1 = Curry.__2(cmp); 22 | return /* module */[/* cmp */cmp$1]; 23 | } 24 | 25 | function MakeHashableU(M) { 26 | var hash = M[/* hash */0]; 27 | var eq = M[/* eq */1]; 28 | return /* module */[ 29 | /* hash */hash, 30 | /* eq */eq 31 | ]; 32 | } 33 | 34 | function MakeHashable(M) { 35 | var hash = M[/* hash */0]; 36 | var hash$1 = Curry.__1(hash); 37 | var eq = M[/* eq */1]; 38 | var eq$1 = Curry.__2(eq); 39 | return /* module */[ 40 | /* hash */hash$1, 41 | /* eq */eq$1 42 | ]; 43 | } 44 | 45 | function hashableU(hash, eq) { 46 | return /* module */[ 47 | /* hash */hash, 48 | /* eq */eq 49 | ]; 50 | } 51 | 52 | function hashable(hash, eq) { 53 | var hash$1 = Curry.__1(hash); 54 | var eq$1 = Curry.__2(eq); 55 | return /* module */[ 56 | /* hash */hash$1, 57 | /* eq */eq$1 58 | ]; 59 | } 60 | 61 | export { 62 | MakeComparableU , 63 | MakeComparable , 64 | comparableU , 65 | comparable , 66 | MakeHashableU , 67 | MakeHashable , 68 | hashableU , 69 | hashable , 70 | 71 | } 72 | /* No side effect */ 73 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_MutableStack.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | 5 | function make() { 6 | return { 7 | root: null 8 | }; 9 | } 10 | 11 | function clear(s) { 12 | s.root = null; 13 | return /* () */0; 14 | } 15 | 16 | function copy(s) { 17 | return { 18 | root: s.root 19 | }; 20 | } 21 | 22 | function push(s, x) { 23 | s.root = { 24 | head: x, 25 | tail: s.root 26 | }; 27 | return /* () */0; 28 | } 29 | 30 | function topUndefined(s) { 31 | var match = s.root; 32 | if (match !== null) { 33 | return match.head; 34 | } else { 35 | return undefined; 36 | } 37 | } 38 | 39 | function top(s) { 40 | var match = s.root; 41 | if (match !== null) { 42 | return /* Some */[match.head]; 43 | } else { 44 | return /* None */0; 45 | } 46 | } 47 | 48 | function isEmpty(s) { 49 | return s.root === null; 50 | } 51 | 52 | function popUndefined(s) { 53 | var match = s.root; 54 | if (match !== null) { 55 | s.root = match.tail; 56 | return match.head; 57 | } else { 58 | return undefined; 59 | } 60 | } 61 | 62 | function pop(s) { 63 | var match = s.root; 64 | if (match !== null) { 65 | s.root = match.tail; 66 | return /* Some */[match.head]; 67 | } else { 68 | return /* None */0; 69 | } 70 | } 71 | 72 | function size(s) { 73 | var match = s.root; 74 | if (match !== null) { 75 | var _x = match; 76 | var _acc = 0; 77 | while(true) { 78 | var acc = _acc; 79 | var x = _x; 80 | var match$1 = x.tail; 81 | if (match$1 !== null) { 82 | _acc = acc + 1 | 0; 83 | _x = match$1; 84 | continue ; 85 | } else { 86 | return acc + 1 | 0; 87 | } 88 | }; 89 | } else { 90 | return 0; 91 | } 92 | } 93 | 94 | function forEachU(s, f) { 95 | var _s = s.root; 96 | var f$1 = f; 97 | while(true) { 98 | var s$1 = _s; 99 | if (s$1 !== null) { 100 | f$1(s$1.head); 101 | _s = s$1.tail; 102 | continue ; 103 | } else { 104 | return /* () */0; 105 | } 106 | }; 107 | } 108 | 109 | function forEach(s, f) { 110 | return forEachU(s, Curry.__1(f)); 111 | } 112 | 113 | function dynamicPopIterU(s, f) { 114 | var cursor = s.root; 115 | while(cursor !== null) { 116 | var v = cursor; 117 | s.root = v.tail; 118 | f(v.head); 119 | cursor = s.root; 120 | }; 121 | return /* () */0; 122 | } 123 | 124 | function dynamicPopIter(s, f) { 125 | return dynamicPopIterU(s, Curry.__1(f)); 126 | } 127 | 128 | export { 129 | make , 130 | clear , 131 | copy , 132 | push , 133 | popUndefined , 134 | pop , 135 | topUndefined , 136 | top , 137 | isEmpty , 138 | size , 139 | forEachU , 140 | forEach , 141 | dynamicPopIterU , 142 | dynamicPopIter , 143 | 144 | } 145 | /* No side effect */ 146 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_Option.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | 5 | function getExn(param) { 6 | if (param) { 7 | return param[0]; 8 | } else { 9 | throw new Error("getExn"); 10 | } 11 | } 12 | 13 | function mapWithDefaultU(opt, $$default, f) { 14 | if (opt) { 15 | return f(opt[0]); 16 | } else { 17 | return $$default; 18 | } 19 | } 20 | 21 | function mapWithDefault(opt, $$default, f) { 22 | return mapWithDefaultU(opt, $$default, Curry.__1(f)); 23 | } 24 | 25 | function mapU(opt, f) { 26 | if (opt) { 27 | return /* Some */[f(opt[0])]; 28 | } else { 29 | return /* None */0; 30 | } 31 | } 32 | 33 | function map(opt, f) { 34 | return mapU(opt, Curry.__1(f)); 35 | } 36 | 37 | function flatMapU(opt, f) { 38 | if (opt) { 39 | return f(opt[0]); 40 | } else { 41 | return /* None */0; 42 | } 43 | } 44 | 45 | function flatMap(opt, f) { 46 | return flatMapU(opt, Curry.__1(f)); 47 | } 48 | 49 | function getWithDefault(opt, $$default) { 50 | if (opt) { 51 | return opt[0]; 52 | } else { 53 | return $$default; 54 | } 55 | } 56 | 57 | function isSome(param) { 58 | if (param) { 59 | return true; 60 | } else { 61 | return false; 62 | } 63 | } 64 | 65 | function isNone(param) { 66 | if (param) { 67 | return false; 68 | } else { 69 | return true; 70 | } 71 | } 72 | 73 | function eqU(a, b, f) { 74 | if (a) { 75 | if (b) { 76 | return f(a[0], b[0]); 77 | } else { 78 | return false; 79 | } 80 | } else if (b) { 81 | return false; 82 | } else { 83 | return true; 84 | } 85 | } 86 | 87 | function eq(a, b, f) { 88 | return eqU(a, b, Curry.__2(f)); 89 | } 90 | 91 | function cmpU(a, b, f) { 92 | if (a) { 93 | if (b) { 94 | return f(a[0], b[0]); 95 | } else { 96 | return 1; 97 | } 98 | } else if (b) { 99 | return -1; 100 | } else { 101 | return 0; 102 | } 103 | } 104 | 105 | function cmp(a, b, f) { 106 | return cmpU(a, b, Curry.__2(f)); 107 | } 108 | 109 | export { 110 | getExn , 111 | mapWithDefaultU , 112 | mapWithDefault , 113 | mapU , 114 | map , 115 | flatMapU , 116 | flatMap , 117 | getWithDefault , 118 | isSome , 119 | isNone , 120 | eqU , 121 | eq , 122 | cmpU , 123 | cmp , 124 | 125 | } 126 | /* No side effect */ 127 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_Range.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | 5 | function forEachU(s, f, action) { 6 | for(var i = s; i <= f; ++i){ 7 | action(i); 8 | } 9 | return /* () */0; 10 | } 11 | 12 | function forEach(s, f, action) { 13 | return forEachU(s, f, Curry.__1(action)); 14 | } 15 | 16 | function everyU(_s, f, p) { 17 | while(true) { 18 | var s = _s; 19 | if (s > f) { 20 | return true; 21 | } else if (p(s)) { 22 | _s = s + 1 | 0; 23 | continue ; 24 | } else { 25 | return false; 26 | } 27 | }; 28 | } 29 | 30 | function every(s, f, p) { 31 | return everyU(s, f, Curry.__1(p)); 32 | } 33 | 34 | function everyByU(s, f, step, p) { 35 | if (step > 0) { 36 | var _s = s; 37 | var f$1 = f; 38 | var step$1 = step; 39 | var p$1 = p; 40 | while(true) { 41 | var s$1 = _s; 42 | if (s$1 > f$1) { 43 | return true; 44 | } else if (p$1(s$1)) { 45 | _s = s$1 + step$1 | 0; 46 | continue ; 47 | } else { 48 | return false; 49 | } 50 | }; 51 | } else { 52 | return true; 53 | } 54 | } 55 | 56 | function everyBy(s, f, step, p) { 57 | return everyByU(s, f, step, Curry.__1(p)); 58 | } 59 | 60 | function someU(_s, f, p) { 61 | while(true) { 62 | var s = _s; 63 | if (s > f) { 64 | return false; 65 | } else if (p(s)) { 66 | return true; 67 | } else { 68 | _s = s + 1 | 0; 69 | continue ; 70 | } 71 | }; 72 | } 73 | 74 | function some(s, f, p) { 75 | return someU(s, f, Curry.__1(p)); 76 | } 77 | 78 | function someByU(s, f, step, p) { 79 | if (step > 0) { 80 | var _s = s; 81 | var f$1 = f; 82 | var step$1 = step; 83 | var p$1 = p; 84 | while(true) { 85 | var s$1 = _s; 86 | if (s$1 > f$1) { 87 | return false; 88 | } else if (p$1(s$1)) { 89 | return true; 90 | } else { 91 | _s = s$1 + step$1 | 0; 92 | continue ; 93 | } 94 | }; 95 | } else { 96 | return false; 97 | } 98 | } 99 | 100 | function someBy(s, f, step, p) { 101 | return someByU(s, f, step, Curry.__1(p)); 102 | } 103 | 104 | export { 105 | forEachU , 106 | forEach , 107 | everyU , 108 | every , 109 | everyByU , 110 | everyBy , 111 | someU , 112 | some , 113 | someByU , 114 | someBy , 115 | 116 | } 117 | /* No side effect */ 118 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_Result.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Block from "stdlib/block.js"; 4 | import * as Curry from "stdlib/curry.js"; 5 | 6 | function getExn(param) { 7 | if (param.tag) { 8 | throw new Error("getExn"); 9 | } else { 10 | return param[0]; 11 | } 12 | } 13 | 14 | function mapWithDefaultU(opt, $$default, f) { 15 | if (opt.tag) { 16 | return $$default; 17 | } else { 18 | return f(opt[0]); 19 | } 20 | } 21 | 22 | function mapWithDefault(opt, $$default, f) { 23 | return mapWithDefaultU(opt, $$default, Curry.__1(f)); 24 | } 25 | 26 | function mapU(opt, f) { 27 | if (opt.tag) { 28 | return /* Error */Block.__(1, [opt[0]]); 29 | } else { 30 | return /* Ok */Block.__(0, [f(opt[0])]); 31 | } 32 | } 33 | 34 | function map(opt, f) { 35 | return mapU(opt, Curry.__1(f)); 36 | } 37 | 38 | function flatMapU(opt, f) { 39 | if (opt.tag) { 40 | return /* Error */Block.__(1, [opt[0]]); 41 | } else { 42 | return f(opt[0]); 43 | } 44 | } 45 | 46 | function flatMap(opt, f) { 47 | return flatMapU(opt, Curry.__1(f)); 48 | } 49 | 50 | function getWithDefault(opt, $$default) { 51 | if (opt.tag) { 52 | return $$default; 53 | } else { 54 | return opt[0]; 55 | } 56 | } 57 | 58 | function isOk(param) { 59 | if (param.tag) { 60 | return false; 61 | } else { 62 | return true; 63 | } 64 | } 65 | 66 | function isError(param) { 67 | if (param.tag) { 68 | return true; 69 | } else { 70 | return false; 71 | } 72 | } 73 | 74 | function eqU(a, b, f) { 75 | if (a.tag) { 76 | if (b.tag) { 77 | return true; 78 | } else { 79 | return false; 80 | } 81 | } else if (b.tag) { 82 | return false; 83 | } else { 84 | return f(a[0], b[0]); 85 | } 86 | } 87 | 88 | function eq(a, b, f) { 89 | return eqU(a, b, Curry.__2(f)); 90 | } 91 | 92 | function cmpU(a, b, f) { 93 | if (a.tag) { 94 | if (b.tag) { 95 | return 0; 96 | } else { 97 | return -1; 98 | } 99 | } else if (b.tag) { 100 | return 1; 101 | } else { 102 | return f(a[0], b[0]); 103 | } 104 | } 105 | 106 | function cmp(a, b, f) { 107 | return cmpU(a, b, Curry.__2(f)); 108 | } 109 | 110 | export { 111 | getExn , 112 | mapWithDefaultU , 113 | mapWithDefault , 114 | mapU , 115 | map , 116 | flatMapU , 117 | flatMap , 118 | getWithDefault , 119 | isOk , 120 | isError , 121 | eqU , 122 | eq , 123 | cmpU , 124 | cmp , 125 | 126 | } 127 | /* No side effect */ 128 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_internalBucketsType.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var emptyOpt = undefined; 5 | 6 | function power_2_above(_x, n) { 7 | while(true) { 8 | var x = _x; 9 | if (x >= n || (x << 1) < x) { 10 | return x; 11 | } else { 12 | _x = (x << 1); 13 | continue ; 14 | } 15 | }; 16 | } 17 | 18 | function make(hash, eq, hintSize) { 19 | var s = power_2_above(16, hintSize); 20 | return { 21 | size: 0, 22 | buckets: new Array(s), 23 | hash: hash, 24 | eq: eq 25 | }; 26 | } 27 | 28 | function clear(h) { 29 | h.size = 0; 30 | var h_buckets = h.buckets; 31 | var len = h_buckets.length; 32 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 33 | h_buckets[i] = emptyOpt; 34 | } 35 | return /* () */0; 36 | } 37 | 38 | function isEmpty(h) { 39 | return h.size === 0; 40 | } 41 | 42 | export { 43 | emptyOpt , 44 | make , 45 | clear , 46 | isEmpty , 47 | 48 | } 49 | /* No side effect */ 50 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_internalSetBuckets.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as Belt_Array from "stdlib/belt_Array.js"; 5 | import * as Belt_internalBucketsType from "stdlib/belt_internalBucketsType.js"; 6 | 7 | function copyAuxCont(_c, _prec) { 8 | while(true) { 9 | var prec = _prec; 10 | var c = _c; 11 | if (c !== undefined) { 12 | var ncopy = { 13 | key: c.key, 14 | next: Belt_internalBucketsType.emptyOpt 15 | }; 16 | prec.next = ncopy; 17 | _prec = ncopy; 18 | _c = c.next; 19 | continue ; 20 | } else { 21 | return /* () */0; 22 | } 23 | }; 24 | } 25 | 26 | function copyBucket(c) { 27 | if (c !== undefined) { 28 | var head = { 29 | key: c.key, 30 | next: Belt_internalBucketsType.emptyOpt 31 | }; 32 | copyAuxCont(c.next, head); 33 | return head; 34 | } else { 35 | return c; 36 | } 37 | } 38 | 39 | function copyBuckets(buckets) { 40 | var len = buckets.length; 41 | var newBuckets = new Array(len); 42 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 43 | newBuckets[i] = copyBucket(buckets[i]); 44 | } 45 | return newBuckets; 46 | } 47 | 48 | function copy(x) { 49 | return { 50 | size: x.size, 51 | buckets: copyBuckets(x.buckets), 52 | hash: x.hash, 53 | eq: x.eq 54 | }; 55 | } 56 | 57 | function bucketLength(_accu, _buckets) { 58 | while(true) { 59 | var buckets = _buckets; 60 | var accu = _accu; 61 | if (buckets !== undefined) { 62 | _buckets = buckets.next; 63 | _accu = accu + 1 | 0; 64 | continue ; 65 | } else { 66 | return accu; 67 | } 68 | }; 69 | } 70 | 71 | function doBucketIter(f, _buckets) { 72 | while(true) { 73 | var buckets = _buckets; 74 | if (buckets !== undefined) { 75 | f(buckets.key); 76 | _buckets = buckets.next; 77 | continue ; 78 | } else { 79 | return /* () */0; 80 | } 81 | }; 82 | } 83 | 84 | function forEachU(h, f) { 85 | var d = h.buckets; 86 | for(var i = 0 ,i_finish = d.length - 1 | 0; i <= i_finish; ++i){ 87 | doBucketIter(f, d[i]); 88 | } 89 | return /* () */0; 90 | } 91 | 92 | function forEach(h, f) { 93 | return forEachU(h, Curry.__1(f)); 94 | } 95 | 96 | function fillArray(_i, arr, _cell) { 97 | while(true) { 98 | var cell = _cell; 99 | var i = _i; 100 | arr[i] = cell.key; 101 | var match = cell.next; 102 | if (match !== undefined) { 103 | _cell = match; 104 | _i = i + 1 | 0; 105 | continue ; 106 | } else { 107 | return i + 1 | 0; 108 | } 109 | }; 110 | } 111 | 112 | function toArray(h) { 113 | var d = h.buckets; 114 | var current = 0; 115 | var arr = new Array(h.size); 116 | for(var i = 0 ,i_finish = d.length - 1 | 0; i <= i_finish; ++i){ 117 | var cell = d[i]; 118 | if (cell !== undefined) { 119 | current = fillArray(current, arr, cell); 120 | } 121 | 122 | } 123 | return arr; 124 | } 125 | 126 | function doBucketFold(f, _b, _accu) { 127 | while(true) { 128 | var accu = _accu; 129 | var b = _b; 130 | if (b !== undefined) { 131 | _accu = f(accu, b.key); 132 | _b = b.next; 133 | continue ; 134 | } else { 135 | return accu; 136 | } 137 | }; 138 | } 139 | 140 | function reduceU(h, init, f) { 141 | var d = h.buckets; 142 | var accu = init; 143 | for(var i = 0 ,i_finish = d.length - 1 | 0; i <= i_finish; ++i){ 144 | accu = doBucketFold(f, d[i], accu); 145 | } 146 | return accu; 147 | } 148 | 149 | function reduce(h, init, f) { 150 | return reduceU(h, init, Curry.__2(f)); 151 | } 152 | 153 | function getMaxBucketLength(h) { 154 | return Belt_Array.reduceU(h.buckets, 0, (function (m, b) { 155 | var len = bucketLength(0, b); 156 | if (m > len) { 157 | return m; 158 | } else { 159 | return len; 160 | } 161 | })); 162 | } 163 | 164 | function getBucketHistogram(h) { 165 | var mbl = getMaxBucketLength(h); 166 | var histo = Belt_Array.makeByU(mbl + 1 | 0, (function () { 167 | return 0; 168 | })); 169 | Belt_Array.forEachU(h.buckets, (function (b) { 170 | var l = bucketLength(0, b); 171 | histo[l] = histo[l] + 1 | 0; 172 | return /* () */0; 173 | })); 174 | return histo; 175 | } 176 | 177 | function logStats(h) { 178 | var histogram = getBucketHistogram(h); 179 | console.log({ 180 | bindings: h.size, 181 | buckets: h.buckets.length, 182 | histogram: histogram 183 | }); 184 | return /* () */0; 185 | } 186 | 187 | var C = 0; 188 | 189 | export { 190 | C , 191 | copy , 192 | forEachU , 193 | forEach , 194 | fillArray , 195 | toArray , 196 | reduceU , 197 | reduce , 198 | logStats , 199 | getBucketHistogram , 200 | 201 | } 202 | /* No side effect */ 203 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_internalSetInt.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Belt_SortArrayInt from "stdlib/belt_SortArrayInt.js"; 4 | import * as Belt_internalAVLset from "stdlib/belt_internalAVLset.js"; 5 | 6 | function has(_t, x) { 7 | while(true) { 8 | var t = _t; 9 | if (t !== null) { 10 | var v = t.value; 11 | if (x === v) { 12 | return true; 13 | } else { 14 | _t = x < v ? t.left : t.right; 15 | continue ; 16 | } 17 | } else { 18 | return false; 19 | } 20 | }; 21 | } 22 | 23 | function compareAux(_e1, _e2) { 24 | while(true) { 25 | var e2 = _e2; 26 | var e1 = _e1; 27 | if (e1 && e2) { 28 | var h2 = e2[0]; 29 | var h1 = e1[0]; 30 | var k1 = h1.value; 31 | var k2 = h2.value; 32 | if (k1 === k2) { 33 | _e2 = Belt_internalAVLset.stackAllLeft(h2.right, e2[1]); 34 | _e1 = Belt_internalAVLset.stackAllLeft(h1.right, e1[1]); 35 | continue ; 36 | } else if (k1 < k2) { 37 | return -1; 38 | } else { 39 | return 1; 40 | } 41 | } else { 42 | return 0; 43 | } 44 | }; 45 | } 46 | 47 | function cmp(s1, s2) { 48 | var len1 = Belt_internalAVLset.size(s1); 49 | var len2 = Belt_internalAVLset.size(s2); 50 | if (len1 === len2) { 51 | return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); 52 | } else if (len1 < len2) { 53 | return -1; 54 | } else { 55 | return 1; 56 | } 57 | } 58 | 59 | function eq(s1, s2) { 60 | return cmp(s1, s2) === 0; 61 | } 62 | 63 | function subset(_s1, _s2) { 64 | while(true) { 65 | var s2 = _s2; 66 | var s1 = _s1; 67 | if (s1 !== null) { 68 | if (s2 !== null) { 69 | var l1 = s1.left; 70 | var v1 = s1.value; 71 | var r1 = s1.right; 72 | var l2 = s2.left; 73 | var v2 = s2.value; 74 | var r2 = s2.right; 75 | if (v1 === v2) { 76 | if (subset(l1, l2)) { 77 | _s2 = r2; 78 | _s1 = r1; 79 | continue ; 80 | } else { 81 | return false; 82 | } 83 | } else if (v1 < v2) { 84 | if (subset(Belt_internalAVLset.create(l1, v1, Belt_internalAVLset.empty), l2)) { 85 | _s1 = r1; 86 | continue ; 87 | } else { 88 | return false; 89 | } 90 | } else if (subset(Belt_internalAVLset.create(Belt_internalAVLset.empty, v1, r1), r2)) { 91 | _s1 = l1; 92 | continue ; 93 | } else { 94 | return false; 95 | } 96 | } else { 97 | return false; 98 | } 99 | } else { 100 | return true; 101 | } 102 | }; 103 | } 104 | 105 | function get(_n, x) { 106 | while(true) { 107 | var n = _n; 108 | if (n !== null) { 109 | var v = n.value; 110 | if (x === v) { 111 | return /* Some */[v]; 112 | } else { 113 | _n = x < v ? n.left : n.right; 114 | continue ; 115 | } 116 | } else { 117 | return /* None */0; 118 | } 119 | }; 120 | } 121 | 122 | function getUndefined(_n, x) { 123 | while(true) { 124 | var n = _n; 125 | if (n !== null) { 126 | var v = n.value; 127 | if (x === v) { 128 | return v; 129 | } else { 130 | _n = x < v ? n.left : n.right; 131 | continue ; 132 | } 133 | } else { 134 | return undefined; 135 | } 136 | }; 137 | } 138 | 139 | function getExn(_n, x) { 140 | while(true) { 141 | var n = _n; 142 | if (n !== null) { 143 | var v = n.value; 144 | if (x === v) { 145 | return v; 146 | } else { 147 | _n = x < v ? n.left : n.right; 148 | continue ; 149 | } 150 | } else { 151 | throw new Error("getExn"); 152 | } 153 | }; 154 | } 155 | 156 | function addMutate(t, x) { 157 | if (t !== null) { 158 | var k = t.value; 159 | if (x === k) { 160 | return t; 161 | } else { 162 | var l = t.left; 163 | var r = t.right; 164 | if (x < k) { 165 | t.left = addMutate(l, x); 166 | } else { 167 | t.right = addMutate(r, x); 168 | } 169 | return Belt_internalAVLset.balMutate(t); 170 | } 171 | } else { 172 | return Belt_internalAVLset.singleton(x); 173 | } 174 | } 175 | 176 | function fromArray(xs) { 177 | var len = xs.length; 178 | if (len === 0) { 179 | return Belt_internalAVLset.empty; 180 | } else { 181 | var next = Belt_SortArrayInt.strictlySortedLength(xs); 182 | var result; 183 | if (next >= 0) { 184 | result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); 185 | } else { 186 | next = -next | 0; 187 | result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); 188 | } 189 | for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 190 | result = addMutate(result, xs[i]); 191 | } 192 | return result; 193 | } 194 | } 195 | 196 | var S = 0; 197 | 198 | var N = 0; 199 | 200 | var A = 0; 201 | 202 | export { 203 | S , 204 | N , 205 | A , 206 | has , 207 | compareAux , 208 | cmp , 209 | eq , 210 | subset , 211 | get , 212 | getUndefined , 213 | getExn , 214 | addMutate , 215 | fromArray , 216 | 217 | } 218 | /* No side effect */ 219 | -------------------------------------------------------------------------------- /runtime/stdlib/belt_internalSetString.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Belt_internalAVLset from "stdlib/belt_internalAVLset.js"; 4 | import * as Belt_SortArrayString from "stdlib/belt_SortArrayString.js"; 5 | 6 | function has(_t, x) { 7 | while(true) { 8 | var t = _t; 9 | if (t !== null) { 10 | var v = t.value; 11 | if (x === v) { 12 | return true; 13 | } else { 14 | _t = x < v ? t.left : t.right; 15 | continue ; 16 | } 17 | } else { 18 | return false; 19 | } 20 | }; 21 | } 22 | 23 | function compareAux(_e1, _e2) { 24 | while(true) { 25 | var e2 = _e2; 26 | var e1 = _e1; 27 | if (e1 && e2) { 28 | var h2 = e2[0]; 29 | var h1 = e1[0]; 30 | var k1 = h1.value; 31 | var k2 = h2.value; 32 | if (k1 === k2) { 33 | _e2 = Belt_internalAVLset.stackAllLeft(h2.right, e2[1]); 34 | _e1 = Belt_internalAVLset.stackAllLeft(h1.right, e1[1]); 35 | continue ; 36 | } else if (k1 < k2) { 37 | return -1; 38 | } else { 39 | return 1; 40 | } 41 | } else { 42 | return 0; 43 | } 44 | }; 45 | } 46 | 47 | function cmp(s1, s2) { 48 | var len1 = Belt_internalAVLset.size(s1); 49 | var len2 = Belt_internalAVLset.size(s2); 50 | if (len1 === len2) { 51 | return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); 52 | } else if (len1 < len2) { 53 | return -1; 54 | } else { 55 | return 1; 56 | } 57 | } 58 | 59 | function eq(s1, s2) { 60 | return cmp(s1, s2) === 0; 61 | } 62 | 63 | function subset(_s1, _s2) { 64 | while(true) { 65 | var s2 = _s2; 66 | var s1 = _s1; 67 | if (s1 !== null) { 68 | if (s2 !== null) { 69 | var l1 = s1.left; 70 | var v1 = s1.value; 71 | var r1 = s1.right; 72 | var l2 = s2.left; 73 | var v2 = s2.value; 74 | var r2 = s2.right; 75 | if (v1 === v2) { 76 | if (subset(l1, l2)) { 77 | _s2 = r2; 78 | _s1 = r1; 79 | continue ; 80 | } else { 81 | return false; 82 | } 83 | } else if (v1 < v2) { 84 | if (subset(Belt_internalAVLset.create(l1, v1, Belt_internalAVLset.empty), l2)) { 85 | _s1 = r1; 86 | continue ; 87 | } else { 88 | return false; 89 | } 90 | } else if (subset(Belt_internalAVLset.create(Belt_internalAVLset.empty, v1, r1), r2)) { 91 | _s1 = l1; 92 | continue ; 93 | } else { 94 | return false; 95 | } 96 | } else { 97 | return false; 98 | } 99 | } else { 100 | return true; 101 | } 102 | }; 103 | } 104 | 105 | function get(_n, x) { 106 | while(true) { 107 | var n = _n; 108 | if (n !== null) { 109 | var v = n.value; 110 | if (x === v) { 111 | return /* Some */[v]; 112 | } else { 113 | _n = x < v ? n.left : n.right; 114 | continue ; 115 | } 116 | } else { 117 | return /* None */0; 118 | } 119 | }; 120 | } 121 | 122 | function getUndefined(_n, x) { 123 | while(true) { 124 | var n = _n; 125 | if (n !== null) { 126 | var v = n.value; 127 | if (x === v) { 128 | return v; 129 | } else { 130 | _n = x < v ? n.left : n.right; 131 | continue ; 132 | } 133 | } else { 134 | return undefined; 135 | } 136 | }; 137 | } 138 | 139 | function getExn(_n, x) { 140 | while(true) { 141 | var n = _n; 142 | if (n !== null) { 143 | var v = n.value; 144 | if (x === v) { 145 | return v; 146 | } else { 147 | _n = x < v ? n.left : n.right; 148 | continue ; 149 | } 150 | } else { 151 | throw new Error("getExn"); 152 | } 153 | }; 154 | } 155 | 156 | function addMutate(t, x) { 157 | if (t !== null) { 158 | var k = t.value; 159 | if (x === k) { 160 | return t; 161 | } else { 162 | var l = t.left; 163 | var r = t.right; 164 | if (x < k) { 165 | t.left = addMutate(l, x); 166 | } else { 167 | t.right = addMutate(r, x); 168 | } 169 | return Belt_internalAVLset.balMutate(t); 170 | } 171 | } else { 172 | return Belt_internalAVLset.singleton(x); 173 | } 174 | } 175 | 176 | function fromArray(xs) { 177 | var len = xs.length; 178 | if (len === 0) { 179 | return Belt_internalAVLset.empty; 180 | } else { 181 | var next = Belt_SortArrayString.strictlySortedLength(xs); 182 | var result; 183 | if (next >= 0) { 184 | result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); 185 | } else { 186 | next = -next | 0; 187 | result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); 188 | } 189 | for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 190 | result = addMutate(result, xs[i]); 191 | } 192 | return result; 193 | } 194 | } 195 | 196 | var S = 0; 197 | 198 | var N = 0; 199 | 200 | var A = 0; 201 | 202 | export { 203 | S , 204 | N , 205 | A , 206 | has , 207 | compareAux , 208 | cmp , 209 | eq , 210 | subset , 211 | get , 212 | getUndefined , 213 | getExn , 214 | addMutate , 215 | fromArray , 216 | 217 | } 218 | /* No side effect */ 219 | -------------------------------------------------------------------------------- /runtime/stdlib/block.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function __(tag, block) { 5 | block.tag = tag; 6 | return block; 7 | } 8 | 9 | function record(meta, xs) { 10 | return Object.defineProperty(xs, Symbol.for("BsRecord"), { 11 | value: meta 12 | }); 13 | } 14 | 15 | function variant(meta, tag, xs) { 16 | xs.tag = tag; 17 | return Object.defineProperty(xs, Symbol.for("BsVariant"), { 18 | value: meta 19 | }); 20 | } 21 | 22 | function simpleVariant(meta, xs) { 23 | return Object.defineProperty(xs, Symbol.for("BsVariant"), { 24 | value: meta 25 | }); 26 | } 27 | 28 | function localModule(meta, xs) { 29 | return Object.defineProperty(xs, Symbol.for("BsLocalModule"), { 30 | value: meta 31 | }); 32 | } 33 | 34 | function polyVar(meta, xs) { 35 | return Object.defineProperty(xs, Symbol.for("BsPolyVar"), { 36 | value: meta 37 | }); 38 | } 39 | 40 | export { 41 | __ , 42 | record , 43 | variant , 44 | simpleVariant , 45 | localModule , 46 | polyVar , 47 | 48 | } 49 | /* No side effect */ 50 | -------------------------------------------------------------------------------- /runtime/stdlib/bs_obj.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/bs_string.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/bytesLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Bytes from "stdlib/bytes.js"; 4 | 5 | var make = Bytes.make; 6 | 7 | var init = Bytes.init; 8 | 9 | var empty = Bytes.empty; 10 | 11 | var copy = Bytes.copy; 12 | 13 | var of_string = Bytes.of_string; 14 | 15 | var to_string = Bytes.to_string; 16 | 17 | var sub = Bytes.sub; 18 | 19 | var sub_string = Bytes.sub_string; 20 | 21 | var fill = Bytes.fill; 22 | 23 | var blit = Bytes.blit; 24 | 25 | var concat = Bytes.concat; 26 | 27 | var iter = Bytes.iter; 28 | 29 | var iteri = Bytes.iteri; 30 | 31 | var map = Bytes.map; 32 | 33 | var mapi = Bytes.mapi; 34 | 35 | var trim = Bytes.trim; 36 | 37 | var escaped = Bytes.escaped; 38 | 39 | var index = Bytes.index; 40 | 41 | var rindex = Bytes.rindex; 42 | 43 | var index_from = Bytes.index_from; 44 | 45 | var rindex_from = Bytes.rindex_from; 46 | 47 | var contains = Bytes.contains; 48 | 49 | var contains_from = Bytes.contains_from; 50 | 51 | var rcontains_from = Bytes.rcontains_from; 52 | 53 | var uppercase = Bytes.uppercase; 54 | 55 | var lowercase = Bytes.lowercase; 56 | 57 | var capitalize = Bytes.capitalize; 58 | 59 | var uncapitalize = Bytes.uncapitalize; 60 | 61 | var compare = Bytes.compare; 62 | 63 | var unsafe_to_string = Bytes.unsafe_to_string; 64 | 65 | var unsafe_of_string = Bytes.unsafe_of_string; 66 | 67 | export { 68 | make , 69 | init , 70 | empty , 71 | copy , 72 | of_string , 73 | to_string , 74 | sub , 75 | sub_string , 76 | fill , 77 | blit , 78 | concat , 79 | iter , 80 | iteri , 81 | map , 82 | mapi , 83 | trim , 84 | escaped , 85 | index , 86 | rindex , 87 | index_from , 88 | rindex_from , 89 | contains , 90 | contains_from , 91 | rcontains_from , 92 | uppercase , 93 | lowercase , 94 | capitalize , 95 | uncapitalize , 96 | compare , 97 | unsafe_to_string , 98 | unsafe_of_string , 99 | 100 | } 101 | /* No side effect */ 102 | -------------------------------------------------------------------------------- /runtime/stdlib/callback.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Obj from "stdlib/obj.js"; 4 | 5 | function register(_, _$1) { 6 | return /* () */0; 7 | } 8 | 9 | function register_exception(_, exn) { 10 | (exn.tag | 0) === Obj.object_tag ? exn : exn[0]; 11 | return /* () */0; 12 | } 13 | 14 | export { 15 | register , 16 | register_exception , 17 | 18 | } 19 | /* No side effect */ 20 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_array.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function caml_array_sub(x, offset, len) { 6 | var result = new Array(len); 7 | var j = 0; 8 | var i = offset; 9 | while(j < len) { 10 | result[j] = x[i]; 11 | j = j + 1 | 0; 12 | i = i + 1 | 0; 13 | }; 14 | return result; 15 | } 16 | 17 | function len(_acc, _l) { 18 | while(true) { 19 | var l = _l; 20 | var acc = _acc; 21 | if (l) { 22 | _l = l[1]; 23 | _acc = l[0].length + acc | 0; 24 | continue ; 25 | } else { 26 | return acc; 27 | } 28 | }; 29 | } 30 | 31 | function fill(arr, _i, _l) { 32 | while(true) { 33 | var l = _l; 34 | var i = _i; 35 | if (l) { 36 | var x = l[0]; 37 | var l$1 = x.length; 38 | var k = i; 39 | var j = 0; 40 | while(j < l$1) { 41 | arr[k] = x[j]; 42 | k = k + 1 | 0; 43 | j = j + 1 | 0; 44 | }; 45 | _l = l[1]; 46 | _i = k; 47 | continue ; 48 | } else { 49 | return /* () */0; 50 | } 51 | }; 52 | } 53 | 54 | function caml_array_concat(l) { 55 | var v = len(0, l); 56 | var result = new Array(v); 57 | fill(result, 0, l); 58 | return result; 59 | } 60 | 61 | function caml_array_set(xs, index, newval) { 62 | if (index < 0 || index >= xs.length) { 63 | throw [ 64 | Caml_builtin_exceptions.invalid_argument, 65 | "index out of bounds" 66 | ]; 67 | } else { 68 | xs[index] = newval; 69 | return /* () */0; 70 | } 71 | } 72 | 73 | function caml_array_get(xs, index) { 74 | if (index < 0 || index >= xs.length) { 75 | throw [ 76 | Caml_builtin_exceptions.invalid_argument, 77 | "index out of bounds" 78 | ]; 79 | } else { 80 | return xs[index]; 81 | } 82 | } 83 | 84 | function caml_make_vect(len, init) { 85 | var b = new Array(len); 86 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 87 | b[i] = init; 88 | } 89 | return b; 90 | } 91 | 92 | function caml_make_float_vect(len) { 93 | var b = new Array(len); 94 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 95 | b[i] = 0; 96 | } 97 | return b; 98 | } 99 | 100 | function caml_array_blit(a1, i1, a2, i2, len) { 101 | if (i2 <= i1) { 102 | for(var j = 0 ,j_finish = len - 1 | 0; j <= j_finish; ++j){ 103 | a2[j + i2 | 0] = a1[j + i1 | 0]; 104 | } 105 | return /* () */0; 106 | } else { 107 | for(var j$1 = len - 1 | 0; j$1 >= 0; --j$1){ 108 | a2[j$1 + i2 | 0] = a1[j$1 + i1 | 0]; 109 | } 110 | return /* () */0; 111 | } 112 | } 113 | 114 | function caml_array_dup(prim) { 115 | return prim.slice(0); 116 | } 117 | 118 | export { 119 | caml_array_dup , 120 | caml_array_sub , 121 | caml_array_concat , 122 | caml_make_vect , 123 | caml_make_float_vect , 124 | caml_array_blit , 125 | caml_array_get , 126 | caml_array_set , 127 | 128 | } 129 | /* No side effect */ 130 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_backtrace.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function caml_convert_raw_backtrace_slot() { 6 | throw [ 7 | Caml_builtin_exceptions.failure, 8 | "caml_convert_raw_backtrace_slot unimplemented" 9 | ]; 10 | } 11 | 12 | export { 13 | caml_convert_raw_backtrace_slot , 14 | 15 | } 16 | /* No side effect */ 17 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_basic.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function some(x) { 5 | return /* Some */[x]; 6 | } 7 | 8 | function is_none(x) { 9 | return x === /* None */0; 10 | } 11 | 12 | function to_def(x) { 13 | if (x) { 14 | return x[0]; 15 | } else { 16 | return undefined; 17 | } 18 | } 19 | 20 | function cons(x, y) { 21 | return /* :: */[ 22 | x, 23 | y 24 | ]; 25 | } 26 | 27 | function is_list_empty(x) { 28 | return x === /* [] */0; 29 | } 30 | 31 | var none = /* None */0; 32 | 33 | export { 34 | none , 35 | some , 36 | is_none , 37 | to_def , 38 | cons , 39 | is_list_empty , 40 | 41 | } 42 | /* No side effect */ 43 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_builtin_exceptions.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var out_of_memory = /* tuple */[ 5 | "Out_of_memory", 6 | 0 7 | ]; 8 | 9 | var sys_error = /* tuple */[ 10 | "Sys_error", 11 | -1 12 | ]; 13 | 14 | var failure = /* tuple */[ 15 | "Failure", 16 | -2 17 | ]; 18 | 19 | var invalid_argument = /* tuple */[ 20 | "Invalid_argument", 21 | -3 22 | ]; 23 | 24 | var end_of_file = /* tuple */[ 25 | "End_of_file", 26 | -4 27 | ]; 28 | 29 | var division_by_zero = /* tuple */[ 30 | "Division_by_zero", 31 | -5 32 | ]; 33 | 34 | var not_found = /* tuple */[ 35 | "Not_found", 36 | -6 37 | ]; 38 | 39 | var match_failure = /* tuple */[ 40 | "Match_failure", 41 | -7 42 | ]; 43 | 44 | var stack_overflow = /* tuple */[ 45 | "Stack_overflow", 46 | -8 47 | ]; 48 | 49 | var sys_blocked_io = /* tuple */[ 50 | "Sys_blocked_io", 51 | -9 52 | ]; 53 | 54 | var assert_failure = /* tuple */[ 55 | "Assert_failure", 56 | -10 57 | ]; 58 | 59 | var undefined_recursive_module = /* tuple */[ 60 | "Undefined_recursive_module", 61 | -11 62 | ]; 63 | 64 | out_of_memory.tag = 248; 65 | 66 | sys_error.tag = 248; 67 | 68 | failure.tag = 248; 69 | 70 | invalid_argument.tag = 248; 71 | 72 | end_of_file.tag = 248; 73 | 74 | division_by_zero.tag = 248; 75 | 76 | not_found.tag = 248; 77 | 78 | match_failure.tag = 248; 79 | 80 | stack_overflow.tag = 248; 81 | 82 | sys_blocked_io.tag = 248; 83 | 84 | assert_failure.tag = 248; 85 | 86 | undefined_recursive_module.tag = 248; 87 | 88 | export { 89 | out_of_memory , 90 | sys_error , 91 | failure , 92 | invalid_argument , 93 | end_of_file , 94 | division_by_zero , 95 | not_found , 96 | match_failure , 97 | stack_overflow , 98 | sys_blocked_io , 99 | assert_failure , 100 | undefined_recursive_module , 101 | 102 | } 103 | /* Not a pure module */ 104 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_bytes.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function get(s, i) { 6 | if (i < 0 || i >= s.length) { 7 | throw [ 8 | Caml_builtin_exceptions.invalid_argument, 9 | "index out of bounds" 10 | ]; 11 | } else { 12 | return s[i]; 13 | } 14 | } 15 | 16 | export { 17 | get , 18 | 19 | } 20 | /* No side effect */ 21 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_exceptions.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var id = [0]; 5 | 6 | function caml_set_oo_id(b) { 7 | b[1] = id[0]; 8 | id[0] += 1; 9 | return b; 10 | } 11 | 12 | function get_id() { 13 | id[0] += 1; 14 | return id[0]; 15 | } 16 | 17 | function create(str) { 18 | var v_001 = get_id(/* () */0); 19 | var v = /* tuple */[ 20 | str, 21 | v_001 22 | ]; 23 | v.tag = 248; 24 | return v; 25 | } 26 | 27 | function isCamlExceptionOrOpenVariant(e) { 28 | if (e === undefined) { 29 | return false; 30 | } else if (e.tag === 248) { 31 | return true; 32 | } else { 33 | var slot = e[0]; 34 | if (slot !== undefined) { 35 | return slot.tag === 248; 36 | } else { 37 | return false; 38 | } 39 | } 40 | } 41 | 42 | export { 43 | caml_set_oo_id , 44 | get_id , 45 | create , 46 | isCamlExceptionOrOpenVariant , 47 | 48 | } 49 | /* No side effect */ 50 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_float.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function caml_int32_float_of_bits(x) { 5 | var int32 = new Int32Array(/* array */[x]); 6 | var float32 = new Float32Array(int32.buffer); 7 | return float32[0]; 8 | } 9 | 10 | function caml_int32_bits_of_float(x) { 11 | var float32 = new Float32Array(/* array */[x]); 12 | return new Int32Array(float32.buffer)[0]; 13 | } 14 | 15 | function caml_classify_float(x) { 16 | if (isFinite(x)) { 17 | if (Math.abs(x) >= 2.2250738585072014e-308) { 18 | return /* FP_normal */0; 19 | } else if (x !== 0) { 20 | return /* FP_subnormal */1; 21 | } else { 22 | return /* FP_zero */2; 23 | } 24 | } else if (isNaN(x)) { 25 | return /* FP_nan */4; 26 | } else { 27 | return /* FP_infinite */3; 28 | } 29 | } 30 | 31 | function caml_modf_float(x) { 32 | if (isFinite(x)) { 33 | var neg = 1 / x < 0; 34 | var x$1 = Math.abs(x); 35 | var i = Math.floor(x$1); 36 | var f = x$1 - i; 37 | if (neg) { 38 | return /* tuple */[ 39 | -f, 40 | -i 41 | ]; 42 | } else { 43 | return /* tuple */[ 44 | f, 45 | i 46 | ]; 47 | } 48 | } else if (isNaN(x)) { 49 | return /* tuple */[ 50 | NaN, 51 | NaN 52 | ]; 53 | } else { 54 | return /* tuple */[ 55 | 1 / x, 56 | x 57 | ]; 58 | } 59 | } 60 | 61 | function caml_ldexp_float(x, exp) { 62 | var x$prime = x; 63 | var exp$prime = exp; 64 | if (exp$prime > 1023) { 65 | exp$prime -= 1023; 66 | x$prime = x$prime * Math.pow(2, 1023); 67 | if (exp$prime > 1023) { 68 | exp$prime -= 1023; 69 | x$prime = x$prime * Math.pow(2, 1023); 70 | } 71 | 72 | } else if (exp$prime < -1023) { 73 | exp$prime += 1023; 74 | x$prime = x$prime * Math.pow(2, -1023); 75 | } 76 | return x$prime * Math.pow(2, exp$prime); 77 | } 78 | 79 | function caml_frexp_float(x) { 80 | if (x === 0 || !isFinite(x)) { 81 | return /* tuple */[ 82 | x, 83 | 0 84 | ]; 85 | } else { 86 | var neg = x < 0; 87 | var x$prime = Math.abs(x); 88 | var exp = Math.floor(Math.LOG2E * Math.log(x$prime)) + 1; 89 | x$prime = x$prime * Math.pow(2, -exp); 90 | if (x$prime < 0.5) { 91 | x$prime = x$prime * 2; 92 | exp -= 1; 93 | } 94 | if (neg) { 95 | x$prime = -x$prime; 96 | } 97 | return /* tuple */[ 98 | x$prime, 99 | exp | 0 100 | ]; 101 | } 102 | } 103 | 104 | function caml_copysign_float(x, y) { 105 | var x$1 = Math.abs(x); 106 | var y$1 = y === 0 ? 1 / y : y; 107 | if (y$1 < 0) { 108 | return -x$1; 109 | } else { 110 | return x$1; 111 | } 112 | } 113 | 114 | function caml_expm1_float(x) { 115 | var y = Math.exp(x); 116 | var z = y - 1; 117 | if (Math.abs(x) > 1) { 118 | return z; 119 | } else if (z === 0) { 120 | return x; 121 | } else { 122 | return x * z / Math.log(y); 123 | } 124 | } 125 | 126 | function caml_hypot_float(x, y) { 127 | var x0 = Math.abs(x); 128 | var y0 = Math.abs(y); 129 | var a = Math.max(x0, y0); 130 | var b = Math.min(x0, y0) / ( 131 | a !== 0 ? a : 1 132 | ); 133 | return a * Math.sqrt(1 + b * b); 134 | } 135 | 136 | function caml_log10_float(x) { 137 | return Math.LOG10E * Math.log(x); 138 | } 139 | 140 | export { 141 | caml_int32_float_of_bits , 142 | caml_int32_bits_of_float , 143 | caml_classify_float , 144 | caml_modf_float , 145 | caml_ldexp_float , 146 | caml_frexp_float , 147 | caml_copysign_float , 148 | caml_expm1_float , 149 | caml_hypot_float , 150 | caml_log10_float , 151 | 152 | } 153 | /* No side effect */ 154 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_gc.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var dummy_stat = /* record */[ 5 | /* minor_words */0, 6 | /* promoted_words */0, 7 | /* major_words */0, 8 | /* minor_collections */0, 9 | /* major_collections */0, 10 | /* heap_words */0, 11 | /* heap_chunks */0, 12 | /* live_words */0, 13 | /* live_blocks */0, 14 | /* free_words */0, 15 | /* free_blocks */0, 16 | /* largest_free */0, 17 | /* fragments */0, 18 | /* compactions */0, 19 | /* top_heap_words */0, 20 | /* stack_size */0 21 | ]; 22 | 23 | function caml_gc_stat() { 24 | return dummy_stat; 25 | } 26 | 27 | function caml_gc_quick_stat() { 28 | return dummy_stat; 29 | } 30 | 31 | function caml_gc_counters() { 32 | return /* tuple */[ 33 | 0, 34 | 0, 35 | 0 36 | ]; 37 | } 38 | 39 | function caml_gc_get() { 40 | return /* record */[ 41 | /* minor_heap_size */0, 42 | /* major_heap_increment */0, 43 | /* space_overhead */0, 44 | /* verbose */0, 45 | /* max_overhead */0, 46 | /* stack_limit */0, 47 | /* allocation_policy */0 48 | ]; 49 | } 50 | 51 | function caml_gc_set() { 52 | return /* () */0; 53 | } 54 | 55 | function caml_gc_minor() { 56 | return /* () */0; 57 | } 58 | 59 | function caml_gc_major_slice() { 60 | return 0; 61 | } 62 | 63 | function caml_gc_major() { 64 | return /* () */0; 65 | } 66 | 67 | function caml_gc_full_major() { 68 | return /* () */0; 69 | } 70 | 71 | function caml_gc_compaction() { 72 | return /* () */0; 73 | } 74 | 75 | function caml_final_register(_, _$1) { 76 | return /* () */0; 77 | } 78 | 79 | function caml_final_release() { 80 | return /* () */0; 81 | } 82 | 83 | export { 84 | caml_gc_stat , 85 | caml_gc_quick_stat , 86 | caml_gc_counters , 87 | caml_gc_get , 88 | caml_gc_set , 89 | caml_gc_minor , 90 | caml_gc_major_slice , 91 | caml_gc_major , 92 | caml_gc_full_major , 93 | caml_gc_compaction , 94 | caml_final_register , 95 | caml_final_release , 96 | 97 | } 98 | /* No side effect */ 99 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_hash.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_queue from "stdlib/caml_queue.js"; 4 | import * as Caml_hash_primitive from "stdlib/caml_hash_primitive.js"; 5 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 6 | 7 | function caml_hash(count, _, seed, obj) { 8 | var hash = seed; 9 | if (typeof obj === "number") { 10 | var u = obj | 0; 11 | hash = Caml_hash_primitive.caml_hash_mix_int(hash, (u + u | 0) + 1 | 0); 12 | return Caml_hash_primitive.caml_hash_final_mix(hash); 13 | } else if (typeof obj === "string") { 14 | hash = Caml_hash_primitive.caml_hash_mix_string(hash, obj); 15 | return Caml_hash_primitive.caml_hash_final_mix(hash); 16 | } else { 17 | var queue = /* record */[ 18 | /* length */0, 19 | /* tail : None */0 20 | ]; 21 | var num = count; 22 | Caml_queue.push(obj, queue); 23 | num = num - 1 | 0; 24 | while(queue[/* length */0] !== 0 && num > 0) { 25 | var obj$1 = Caml_queue.unsafe_pop(queue); 26 | if (typeof obj$1 === "number") { 27 | var u$1 = obj$1 | 0; 28 | hash = Caml_hash_primitive.caml_hash_mix_int(hash, (u$1 + u$1 | 0) + 1 | 0); 29 | num = num - 1 | 0; 30 | } else if (typeof obj$1 === "string") { 31 | hash = Caml_hash_primitive.caml_hash_mix_string(hash, obj$1); 32 | num = num - 1 | 0; 33 | } else if (typeof obj$1 !== "boolean") { 34 | if (typeof obj$1 !== "undefined") { 35 | if (typeof obj$1 === "symbol") { 36 | throw [ 37 | Caml_builtin_exceptions.assert_failure, 38 | [ 39 | "caml_hash.ml", 40 | 72, 41 | 8 42 | ] 43 | ]; 44 | } else if (typeof obj$1 !== "function") { 45 | var size = obj$1.length; 46 | if (size !== undefined) { 47 | var obj_tag = obj$1.tag | 0; 48 | var tag = (size << 10) | obj_tag; 49 | if (tag === 248) { 50 | hash = Caml_hash_primitive.caml_hash_mix_int(hash, obj$1[1]); 51 | } else { 52 | hash = Caml_hash_primitive.caml_hash_mix_int(hash, tag); 53 | var v = size - 1 | 0; 54 | var block = v < num ? v : num; 55 | for(var i = 0; i <= block; ++i){ 56 | Caml_queue.push(obj$1[i], queue); 57 | } 58 | } 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | } 66 | 67 | }; 68 | return Caml_hash_primitive.caml_hash_final_mix(hash); 69 | } 70 | } 71 | 72 | export { 73 | caml_hash , 74 | 75 | } 76 | /* No side effect */ 77 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_hash_primitive.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_int32 from "stdlib/caml_int32.js"; 4 | 5 | function rotl32(x, n) { 6 | return (x << n) | (x >>> (32 - n | 0)); 7 | } 8 | 9 | function caml_hash_mix_int(h, d) { 10 | var d$1 = d; 11 | d$1 = Caml_int32.imul(d$1, 3432918353); 12 | d$1 = rotl32(d$1, 15); 13 | d$1 = Caml_int32.imul(d$1, 461845907); 14 | var h$1 = h ^ d$1; 15 | h$1 = rotl32(h$1, 13); 16 | return (h$1 + (h$1 << 2) | 0) + 3864292196 | 0; 17 | } 18 | 19 | function caml_hash_final_mix(h) { 20 | var h$1 = h ^ (h >>> 16); 21 | h$1 = Caml_int32.imul(h$1, 2246822507); 22 | h$1 = h$1 ^ (h$1 >>> 13); 23 | h$1 = Caml_int32.imul(h$1, 3266489909); 24 | return h$1 ^ (h$1 >>> 16); 25 | } 26 | 27 | function caml_hash_mix_string(h, s) { 28 | var len = s.length; 29 | var block = (len / 4 | 0) - 1 | 0; 30 | var hash = h; 31 | for(var i = 0; i <= block; ++i){ 32 | var j = (i << 2); 33 | var w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24); 34 | hash = caml_hash_mix_int(hash, w); 35 | } 36 | var modulo = len & 3; 37 | if (modulo !== 0) { 38 | var w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : ( 39 | modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0) 40 | ); 41 | hash = caml_hash_mix_int(hash, w$1); 42 | } 43 | hash = hash ^ len; 44 | return hash; 45 | } 46 | 47 | export { 48 | caml_hash_mix_int , 49 | caml_hash_mix_string , 50 | caml_hash_final_mix , 51 | 52 | } 53 | /* No side effect */ 54 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_int32.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function div(x, y) { 6 | if (y === 0) { 7 | throw Caml_builtin_exceptions.division_by_zero; 8 | } else { 9 | return x / y | 0; 10 | } 11 | } 12 | 13 | function mod_(x, y) { 14 | if (y === 0) { 15 | throw Caml_builtin_exceptions.division_by_zero; 16 | } else { 17 | return x % y; 18 | } 19 | } 20 | 21 | function caml_bswap16(x) { 22 | return ((x & 255) << 8) | ((x & 65280) >>> 8); 23 | } 24 | 25 | function caml_int32_bswap(x) { 26 | return ((x & 255) << 24) | ((x & 65280) << 8) | ((x & 16711680) >>> 8) | ((x & 4278190080) >>> 24); 27 | } 28 | 29 | var imul = ( Math.imul || function (x,y) { 30 | y |= 0; return ((((x >> 16) * y) << 16) + (x & 0xffff) * y)|0; 31 | } 32 | ); 33 | 34 | var caml_nativeint_bswap = caml_int32_bswap; 35 | 36 | export { 37 | div , 38 | mod_ , 39 | caml_bswap16 , 40 | caml_int32_bswap , 41 | caml_nativeint_bswap , 42 | imul , 43 | 44 | } 45 | /* imul Not a pure module */ 46 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_io.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 5 | 6 | function $caret(prim, prim$1) { 7 | return prim + prim$1; 8 | } 9 | 10 | var stdout = /* record */[ 11 | /* buffer */"", 12 | /* output */(function (_, s) { 13 | var v = s.length - 1 | 0; 14 | if (( (typeof process !== "undefined") && process.stdout && process.stdout.write)) { 15 | return ( process.stdout.write )(s); 16 | } else if (s[v] === "\n") { 17 | console.log(s.slice(0, v)); 18 | return /* () */0; 19 | } else { 20 | console.log(s); 21 | return /* () */0; 22 | } 23 | }) 24 | ]; 25 | 26 | var stderr = /* record */[ 27 | /* buffer */"", 28 | /* output */(function (_, s) { 29 | var v = s.length - 1 | 0; 30 | if (s[v] === "\n") { 31 | console.log(s.slice(0, v)); 32 | return /* () */0; 33 | } else { 34 | console.log(s); 35 | return /* () */0; 36 | } 37 | }) 38 | ]; 39 | 40 | function caml_ml_open_descriptor_in() { 41 | throw [ 42 | Caml_builtin_exceptions.failure, 43 | "caml_ml_open_descriptor_in not implemented" 44 | ]; 45 | } 46 | 47 | function caml_ml_open_descriptor_out() { 48 | throw [ 49 | Caml_builtin_exceptions.failure, 50 | "caml_ml_open_descriptor_out not implemented" 51 | ]; 52 | } 53 | 54 | function caml_ml_flush(oc) { 55 | if (oc[/* buffer */0] !== "") { 56 | Curry._2(oc[/* output */1], oc, oc[/* buffer */0]); 57 | oc[/* buffer */0] = ""; 58 | return /* () */0; 59 | } else { 60 | return 0; 61 | } 62 | } 63 | 64 | var node_std_output = (function (s){ 65 | return (typeof process !== "undefined") && process.stdout && (process.stdout.write(s), true); 66 | } 67 | ); 68 | 69 | function caml_ml_output(oc, str, offset, len) { 70 | var str$1 = offset === 0 && len === str.length ? str : str.slice(offset, len); 71 | if (( (typeof process !== "undefined") && process.stdout && process.stdout.write ) && oc === stdout) { 72 | return ( process.stdout.write )(str$1); 73 | } else { 74 | var id = str$1.lastIndexOf("\n"); 75 | if (id < 0) { 76 | oc[/* buffer */0] = oc[/* buffer */0] + str$1; 77 | return /* () */0; 78 | } else { 79 | oc[/* buffer */0] = oc[/* buffer */0] + str$1.slice(0, id + 1 | 0); 80 | caml_ml_flush(oc); 81 | oc[/* buffer */0] = oc[/* buffer */0] + str$1.slice(id + 1 | 0); 82 | return /* () */0; 83 | } 84 | } 85 | } 86 | 87 | function caml_ml_output_char(oc, $$char) { 88 | return caml_ml_output(oc, String.fromCharCode($$char), 0, 1); 89 | } 90 | 91 | function caml_ml_input(_, _$1, _$2, _$3) { 92 | throw [ 93 | Caml_builtin_exceptions.failure, 94 | "caml_ml_input ic not implemented" 95 | ]; 96 | } 97 | 98 | function caml_ml_input_char() { 99 | throw [ 100 | Caml_builtin_exceptions.failure, 101 | "caml_ml_input_char not implemnted" 102 | ]; 103 | } 104 | 105 | function caml_ml_out_channels_list() { 106 | return /* :: */[ 107 | stdout, 108 | /* :: */[ 109 | stderr, 110 | /* [] */0 111 | ] 112 | ]; 113 | } 114 | 115 | var stdin = undefined; 116 | 117 | export { 118 | $caret , 119 | stdin , 120 | stdout , 121 | stderr , 122 | caml_ml_open_descriptor_in , 123 | caml_ml_open_descriptor_out , 124 | caml_ml_flush , 125 | node_std_output , 126 | caml_ml_output , 127 | caml_ml_output_char , 128 | caml_ml_input , 129 | caml_ml_input_char , 130 | caml_ml_out_channels_list , 131 | 132 | } 133 | /* node_std_output Not a pure module */ 134 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_md5.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function cmn(q, a, b, x, s, t) { 5 | var a$1 = ((a + q | 0) + x | 0) + t | 0; 6 | return ((a$1 << s) | (a$1 >>> (32 - s | 0)) | 0) + b | 0; 7 | } 8 | 9 | function f(a, b, c, d, x, s, t) { 10 | return cmn(b & c | (b ^ -1) & d, a, b, x, s, t); 11 | } 12 | 13 | function g(a, b, c, d, x, s, t) { 14 | return cmn(b & d | c & (d ^ -1), a, b, x, s, t); 15 | } 16 | 17 | function h(a, b, c, d, x, s, t) { 18 | return cmn(b ^ c ^ d, a, b, x, s, t); 19 | } 20 | 21 | function i(a, b, c, d, x, s, t) { 22 | return cmn(c ^ (b | d ^ -1), a, b, x, s, t); 23 | } 24 | 25 | function cycle(x, k) { 26 | var a = x[0]; 27 | var b = x[1]; 28 | var c = x[2]; 29 | var d = x[3]; 30 | a = f(a, b, c, d, k[0], 7, -680876936); 31 | d = f(d, a, b, c, k[1], 12, -389564586); 32 | c = f(c, d, a, b, k[2], 17, 606105819); 33 | b = f(b, c, d, a, k[3], 22, -1044525330); 34 | a = f(a, b, c, d, k[4], 7, -176418897); 35 | d = f(d, a, b, c, k[5], 12, 1200080426); 36 | c = f(c, d, a, b, k[6], 17, -1473231341); 37 | b = f(b, c, d, a, k[7], 22, -45705983); 38 | a = f(a, b, c, d, k[8], 7, 1770035416); 39 | d = f(d, a, b, c, k[9], 12, -1958414417); 40 | c = f(c, d, a, b, k[10], 17, -42063); 41 | b = f(b, c, d, a, k[11], 22, -1990404162); 42 | a = f(a, b, c, d, k[12], 7, 1804603682); 43 | d = f(d, a, b, c, k[13], 12, -40341101); 44 | c = f(c, d, a, b, k[14], 17, -1502002290); 45 | b = f(b, c, d, a, k[15], 22, 1236535329); 46 | a = g(a, b, c, d, k[1], 5, -165796510); 47 | d = g(d, a, b, c, k[6], 9, -1069501632); 48 | c = g(c, d, a, b, k[11], 14, 643717713); 49 | b = g(b, c, d, a, k[0], 20, -373897302); 50 | a = g(a, b, c, d, k[5], 5, -701558691); 51 | d = g(d, a, b, c, k[10], 9, 38016083); 52 | c = g(c, d, a, b, k[15], 14, -660478335); 53 | b = g(b, c, d, a, k[4], 20, -405537848); 54 | a = g(a, b, c, d, k[9], 5, 568446438); 55 | d = g(d, a, b, c, k[14], 9, -1019803690); 56 | c = g(c, d, a, b, k[3], 14, -187363961); 57 | b = g(b, c, d, a, k[8], 20, 1163531501); 58 | a = g(a, b, c, d, k[13], 5, -1444681467); 59 | d = g(d, a, b, c, k[2], 9, -51403784); 60 | c = g(c, d, a, b, k[7], 14, 1735328473); 61 | b = g(b, c, d, a, k[12], 20, -1926607734); 62 | a = h(a, b, c, d, k[5], 4, -378558); 63 | d = h(d, a, b, c, k[8], 11, -2022574463); 64 | c = h(c, d, a, b, k[11], 16, 1839030562); 65 | b = h(b, c, d, a, k[14], 23, -35309556); 66 | a = h(a, b, c, d, k[1], 4, -1530992060); 67 | d = h(d, a, b, c, k[4], 11, 1272893353); 68 | c = h(c, d, a, b, k[7], 16, -155497632); 69 | b = h(b, c, d, a, k[10], 23, -1094730640); 70 | a = h(a, b, c, d, k[13], 4, 681279174); 71 | d = h(d, a, b, c, k[0], 11, -358537222); 72 | c = h(c, d, a, b, k[3], 16, -722521979); 73 | b = h(b, c, d, a, k[6], 23, 76029189); 74 | a = h(a, b, c, d, k[9], 4, -640364487); 75 | d = h(d, a, b, c, k[12], 11, -421815835); 76 | c = h(c, d, a, b, k[15], 16, 530742520); 77 | b = h(b, c, d, a, k[2], 23, -995338651); 78 | a = i(a, b, c, d, k[0], 6, -198630844); 79 | d = i(d, a, b, c, k[7], 10, 1126891415); 80 | c = i(c, d, a, b, k[14], 15, -1416354905); 81 | b = i(b, c, d, a, k[5], 21, -57434055); 82 | a = i(a, b, c, d, k[12], 6, 1700485571); 83 | d = i(d, a, b, c, k[3], 10, -1894986606); 84 | c = i(c, d, a, b, k[10], 15, -1051523); 85 | b = i(b, c, d, a, k[1], 21, -2054922799); 86 | a = i(a, b, c, d, k[8], 6, 1873313359); 87 | d = i(d, a, b, c, k[15], 10, -30611744); 88 | c = i(c, d, a, b, k[6], 15, -1560198380); 89 | b = i(b, c, d, a, k[13], 21, 1309151649); 90 | a = i(a, b, c, d, k[4], 6, -145523070); 91 | d = i(d, a, b, c, k[11], 10, -1120210379); 92 | c = i(c, d, a, b, k[2], 15, 718787259); 93 | b = i(b, c, d, a, k[9], 21, -343485551); 94 | x[0] = a + x[0] | 0; 95 | x[1] = b + x[1] | 0; 96 | x[2] = c + x[2] | 0; 97 | x[3] = d + x[3] | 0; 98 | return /* () */0; 99 | } 100 | 101 | var state = /* array */[ 102 | 1732584193, 103 | -271733879, 104 | -1732584194, 105 | 271733878 106 | ]; 107 | 108 | var md5blk = /* array */[ 109 | 0, 110 | 0, 111 | 0, 112 | 0, 113 | 0, 114 | 0, 115 | 0, 116 | 0, 117 | 0, 118 | 0, 119 | 0, 120 | 0, 121 | 0, 122 | 0, 123 | 0, 124 | 0 125 | ]; 126 | 127 | function caml_md5_string(s, start, len) { 128 | var s$1 = s.slice(start, len); 129 | var n = s$1.length; 130 | state[0] = 1732584193; 131 | state[1] = -271733879; 132 | state[2] = -1732584194; 133 | state[3] = 271733878; 134 | for(var i = 0; i <= 15; ++i){ 135 | md5blk[i] = 0; 136 | } 137 | var i_end = n / 64 | 0; 138 | for(var i$1 = 1; i$1 <= i_end; ++i$1){ 139 | for(var j = 0; j <= 15; ++j){ 140 | var k = ((i$1 << 6) - 64 | 0) + (j << 2) | 0; 141 | md5blk[j] = ((s$1.charCodeAt(k) + (s$1.charCodeAt(k + 1 | 0) << 8) | 0) + (s$1.charCodeAt(k + 2 | 0) << 16) | 0) + (s$1.charCodeAt(k + 3 | 0) << 24) | 0; 142 | } 143 | cycle(state, md5blk); 144 | } 145 | var s_tail = s$1.slice((i_end << 6)); 146 | for(var kk = 0; kk <= 15; ++kk){ 147 | md5blk[kk] = 0; 148 | } 149 | var i_end$1 = s_tail.length - 1 | 0; 150 | for(var i$2 = 0; i$2 <= i_end$1; ++i$2){ 151 | md5blk[i$2 / 4 | 0] = md5blk[i$2 / 4 | 0] | (s_tail.charCodeAt(i$2) << (i$2 % 4 << 3)); 152 | } 153 | var i$3 = i_end$1 + 1 | 0; 154 | md5blk[i$3 / 4 | 0] = md5blk[i$3 / 4 | 0] | (128 << (i$3 % 4 << 3)); 155 | if (i$3 > 55) { 156 | cycle(state, md5blk); 157 | for(var i$4 = 0; i$4 <= 15; ++i$4){ 158 | md5blk[i$4] = 0; 159 | } 160 | } 161 | md5blk[14] = (n << 3); 162 | cycle(state, md5blk); 163 | return String.fromCharCode(state[0] & 255, (state[0] >> 8) & 255, (state[0] >> 16) & 255, (state[0] >> 24) & 255, state[1] & 255, (state[1] >> 8) & 255, (state[1] >> 16) & 255, (state[1] >> 24) & 255, state[2] & 255, (state[2] >> 8) & 255, (state[2] >> 16) & 255, (state[2] >> 24) & 255, state[3] & 255, (state[3] >> 8) & 255, (state[3] >> 16) & 255, (state[3] >> 24) & 255); 164 | } 165 | 166 | export { 167 | caml_md5_string , 168 | 169 | } 170 | /* No side effect */ 171 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_missing_polyfill.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function not_implemented(s) { 5 | var str = s + " not implemented by BuckleScript yet\n"; 6 | throw new Error(str); 7 | } 8 | 9 | export { 10 | not_implemented , 11 | 12 | } 13 | /* No side effect */ 14 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_module.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_obj from "stdlib/caml_obj.js"; 4 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 5 | 6 | function init_mod(loc, shape) { 7 | var undef_module = function () { 8 | throw [ 9 | Caml_builtin_exceptions.undefined_recursive_module, 10 | loc 11 | ]; 12 | }; 13 | var loop = function (shape, struct_, idx) { 14 | if (typeof shape === "number") { 15 | switch (shape) { 16 | case 0 : 17 | case 1 : 18 | struct_[idx] = undef_module; 19 | return /* () */0; 20 | case 2 : 21 | struct_[idx] = /* tuple */[ 22 | undef_module, 23 | undef_module, 24 | undef_module, 25 | 0 26 | ]; 27 | return /* () */0; 28 | 29 | } 30 | } else if (shape.tag) { 31 | struct_[idx] = shape[0]; 32 | return /* () */0; 33 | } else { 34 | var comps = shape[0]; 35 | var v = /* array */[]; 36 | struct_[idx] = v; 37 | var len = comps.length; 38 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 39 | loop(comps[i], v, i); 40 | } 41 | return /* () */0; 42 | } 43 | }; 44 | var res = /* array */[]; 45 | loop(shape, res, 0); 46 | return res[0]; 47 | } 48 | 49 | function update_mod(shape, o, n) { 50 | var aux = function (shape, o, n, parent, i) { 51 | if (typeof shape === "number") { 52 | switch (shape) { 53 | case 0 : 54 | parent[i] = n; 55 | return /* () */0; 56 | case 1 : 57 | case 2 : 58 | return Caml_obj.caml_update_dummy(o, n); 59 | 60 | } 61 | } else if (shape.tag) { 62 | return /* () */0; 63 | } else { 64 | var comps = shape[0]; 65 | for(var i$1 = 0 ,i_finish = comps.length - 1 | 0; i$1 <= i_finish; ++i$1){ 66 | aux(comps[i$1], o[i$1], n[i$1], o, i$1); 67 | } 68 | return /* () */0; 69 | } 70 | }; 71 | if (typeof shape === "number") { 72 | throw [ 73 | Caml_builtin_exceptions.assert_failure, 74 | [ 75 | "caml_module.ml", 76 | 82, 77 | 10 78 | ] 79 | ]; 80 | } else if (shape.tag) { 81 | throw [ 82 | Caml_builtin_exceptions.assert_failure, 83 | [ 84 | "caml_module.ml", 85 | 82, 86 | 10 87 | ] 88 | ]; 89 | } else { 90 | var comps = shape[0]; 91 | for(var i = 0 ,i_finish = comps.length - 1 | 0; i <= i_finish; ++i){ 92 | aux(comps[i], o[i], n[i], o, i); 93 | } 94 | return /* () */0; 95 | } 96 | } 97 | 98 | export { 99 | init_mod , 100 | update_mod , 101 | 102 | } 103 | /* No side effect */ 104 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_oo.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_array from "stdlib/caml_array.js"; 4 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 5 | 6 | var caml_methods_cache = Caml_array.caml_make_vect(1000, 0); 7 | 8 | function caml_get_public_method(obj, tag, cacheid) { 9 | var meths = obj[0]; 10 | var offs = caml_methods_cache[cacheid]; 11 | if (meths[offs] === tag) { 12 | return meths[offs - 1 | 0]; 13 | } else { 14 | var aux = function (_i) { 15 | while(true) { 16 | var i = _i; 17 | if (i < 3) { 18 | throw [ 19 | Caml_builtin_exceptions.assert_failure, 20 | [ 21 | "caml_oo.ml", 22 | 59, 23 | 20 24 | ] 25 | ]; 26 | } else if (meths[i] === tag) { 27 | caml_methods_cache[cacheid] = i; 28 | return i; 29 | } else { 30 | _i = i - 2 | 0; 31 | continue ; 32 | } 33 | }; 34 | }; 35 | return meths[aux((meths[0] << 1) + 1 | 0) - 1 | 0]; 36 | } 37 | } 38 | 39 | export { 40 | caml_get_public_method , 41 | 42 | } 43 | /* No side effect */ 44 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_oo_curry.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as Caml_oo from "stdlib/caml_oo.js"; 5 | 6 | function js(label, cacheid, obj, args) { 7 | var meth = Caml_oo.caml_get_public_method(obj, label, cacheid); 8 | return Curry.app(meth, args); 9 | } 10 | 11 | function js1(label, cacheid, a0) { 12 | return Curry._1(Caml_oo.caml_get_public_method(a0, label, cacheid), a0); 13 | } 14 | 15 | function js2(label, cacheid, a0, a1) { 16 | return Curry._2(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1); 17 | } 18 | 19 | function js3(label, cacheid, a0, a1, a2) { 20 | return Curry._3(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2); 21 | } 22 | 23 | function js4(label, cacheid, a0, a1, a2, a3) { 24 | return Curry._4(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3); 25 | } 26 | 27 | function js5(label, cacheid, a0, a1, a2, a3, a4) { 28 | return Curry._5(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4); 29 | } 30 | 31 | function js6(label, cacheid, a0, a1, a2, a3, a4, a5) { 32 | return Curry._6(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5); 33 | } 34 | 35 | function js7(label, cacheid, a0, a1, a2, a3, a4, a5, a6) { 36 | return Curry._7(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5, a6); 37 | } 38 | 39 | function js8(label, cacheid, a0, a1, a2, a3, a4, a5, a6, a7) { 40 | return Curry._8(Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5, a6, a7); 41 | } 42 | 43 | export { 44 | js , 45 | js1 , 46 | js2 , 47 | js3 , 48 | js4 , 49 | js5 , 50 | js6 , 51 | js7 , 52 | js8 , 53 | 54 | } 55 | /* No side effect */ 56 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_primitive.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function caml_int_compare(x, y) { 5 | if (x < y) { 6 | return -1; 7 | } else if (x === y) { 8 | return 0; 9 | } else { 10 | return 1; 11 | } 12 | } 13 | 14 | function caml_bool_compare(x, y) { 15 | if (x) { 16 | if (y) { 17 | return 0; 18 | } else { 19 | return 1; 20 | } 21 | } else if (y) { 22 | return -1; 23 | } else { 24 | return 0; 25 | } 26 | } 27 | 28 | function caml_float_compare(x, y) { 29 | if (x === y) { 30 | return 0; 31 | } else if (x < y) { 32 | return -1; 33 | } else if (x > y || x === x) { 34 | return 1; 35 | } else if (y === y) { 36 | return -1; 37 | } else { 38 | return 0; 39 | } 40 | } 41 | 42 | function caml_string_compare(s1, s2) { 43 | if (s1 === s2) { 44 | return 0; 45 | } else if (s1 < s2) { 46 | return -1; 47 | } else { 48 | return 1; 49 | } 50 | } 51 | 52 | function caml_bool_min(x, y) { 53 | if (x) { 54 | return y; 55 | } else { 56 | return x; 57 | } 58 | } 59 | 60 | function caml_int_min(x, y) { 61 | if (x < y) { 62 | return x; 63 | } else { 64 | return y; 65 | } 66 | } 67 | 68 | function caml_float_min(x, y) { 69 | if (x < y) { 70 | return x; 71 | } else { 72 | return y; 73 | } 74 | } 75 | 76 | function caml_string_min(x, y) { 77 | if (x < y) { 78 | return x; 79 | } else { 80 | return y; 81 | } 82 | } 83 | 84 | function caml_nativeint_min(x, y) { 85 | if (x < y) { 86 | return x; 87 | } else { 88 | return y; 89 | } 90 | } 91 | 92 | function caml_int32_min(x, y) { 93 | if (x < y) { 94 | return x; 95 | } else { 96 | return y; 97 | } 98 | } 99 | 100 | function caml_bool_max(x, y) { 101 | if (x) { 102 | return x; 103 | } else { 104 | return y; 105 | } 106 | } 107 | 108 | function caml_int_max(x, y) { 109 | if (x > y) { 110 | return x; 111 | } else { 112 | return y; 113 | } 114 | } 115 | 116 | function caml_float_max(x, y) { 117 | if (x > y) { 118 | return x; 119 | } else { 120 | return y; 121 | } 122 | } 123 | 124 | function caml_string_max(x, y) { 125 | if (x > y) { 126 | return x; 127 | } else { 128 | return y; 129 | } 130 | } 131 | 132 | function caml_nativeint_max(x, y) { 133 | if (x > y) { 134 | return x; 135 | } else { 136 | return y; 137 | } 138 | } 139 | 140 | function caml_int32_max(x, y) { 141 | if (x > y) { 142 | return x; 143 | } else { 144 | return y; 145 | } 146 | } 147 | 148 | var caml_nativeint_compare = caml_int_compare; 149 | 150 | var caml_int32_compare = caml_int_compare; 151 | 152 | export { 153 | caml_int_compare , 154 | caml_bool_compare , 155 | caml_float_compare , 156 | caml_nativeint_compare , 157 | caml_string_compare , 158 | caml_int32_compare , 159 | caml_bool_min , 160 | caml_int_min , 161 | caml_float_min , 162 | caml_string_min , 163 | caml_nativeint_min , 164 | caml_int32_min , 165 | caml_bool_max , 166 | caml_int_max , 167 | caml_float_max , 168 | caml_string_max , 169 | caml_nativeint_max , 170 | caml_int32_max , 171 | 172 | } 173 | /* No side effect */ 174 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_queue.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function create() { 5 | return /* record */[ 6 | /* length */0, 7 | /* tail : None */0 8 | ]; 9 | } 10 | 11 | function push(x, q) { 12 | if (q[/* length */0] === 0) { 13 | var cell = []; 14 | cell[0] = x; 15 | cell[1] = cell; 16 | q[/* length */0] = 1; 17 | q[/* tail */1] = cell; 18 | return /* () */0; 19 | } else { 20 | var tail = q[/* tail */1]; 21 | var head = tail[/* next */1]; 22 | var cell$1 = /* record */[ 23 | /* content */x, 24 | /* next */head 25 | ]; 26 | q[/* length */0] = q[/* length */0] + 1 | 0; 27 | tail[/* next */1] = cell$1; 28 | q[/* tail */1] = cell$1; 29 | return /* () */0; 30 | } 31 | } 32 | 33 | function unsafe_pop(q) { 34 | q[/* length */0] = q[/* length */0] - 1 | 0; 35 | var tail = q[/* tail */1]; 36 | var head = tail[/* next */1]; 37 | if (head === tail) { 38 | q[/* tail */1] = /* None */0; 39 | } else { 40 | tail[/* next */1] = head[/* next */1]; 41 | } 42 | return head[/* content */0]; 43 | } 44 | 45 | function is_empty(q) { 46 | return q[/* length */0] === 0; 47 | } 48 | 49 | export { 50 | create , 51 | push , 52 | unsafe_pop , 53 | is_empty , 54 | 55 | } 56 | /* No side effect */ 57 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_string.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function string_of_char(prim) { 6 | return String.fromCharCode(prim); 7 | } 8 | 9 | function caml_string_get(s, i) { 10 | if (i >= s.length || i < 0) { 11 | throw [ 12 | Caml_builtin_exceptions.invalid_argument, 13 | "index out of bounds" 14 | ]; 15 | } else { 16 | return s.charCodeAt(i); 17 | } 18 | } 19 | 20 | function caml_create_string(len) { 21 | if (len < 0) { 22 | throw [ 23 | Caml_builtin_exceptions.invalid_argument, 24 | "String.create" 25 | ]; 26 | } else { 27 | var result = new Array(len); 28 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 29 | result[i] = /* "\000" */0; 30 | } 31 | return result; 32 | } 33 | } 34 | 35 | function caml_fill_string(s, i, l, c) { 36 | if (l > 0) { 37 | for(var k = i ,k_finish = (l + i | 0) - 1 | 0; k <= k_finish; ++k){ 38 | s[k] = c; 39 | } 40 | return /* () */0; 41 | } else { 42 | return 0; 43 | } 44 | } 45 | 46 | function caml_blit_string(s1, i1, s2, i2, len) { 47 | if (len > 0) { 48 | var off1 = s1.length - i1 | 0; 49 | if (len <= off1) { 50 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 51 | s2[i2 + i | 0] = s1.charCodeAt(i1 + i | 0); 52 | } 53 | return /* () */0; 54 | } else { 55 | for(var i$1 = 0 ,i_finish$1 = off1 - 1 | 0; i$1 <= i_finish$1; ++i$1){ 56 | s2[i2 + i$1 | 0] = s1.charCodeAt(i1 + i$1 | 0); 57 | } 58 | for(var i$2 = off1 ,i_finish$2 = len - 1 | 0; i$2 <= i_finish$2; ++i$2){ 59 | s2[i2 + i$2 | 0] = /* "\000" */0; 60 | } 61 | return /* () */0; 62 | } 63 | } else { 64 | return 0; 65 | } 66 | } 67 | 68 | function caml_blit_bytes(s1, i1, s2, i2, len) { 69 | if (len > 0) { 70 | if (s1 === s2) { 71 | var s1$1 = s1; 72 | var i1$1 = i1; 73 | var i2$1 = i2; 74 | var len$1 = len; 75 | if (i1$1 < i2$1) { 76 | var range_a = (s1$1.length - i2$1 | 0) - 1 | 0; 77 | var range_b = len$1 - 1 | 0; 78 | var range = range_a > range_b ? range_b : range_a; 79 | for(var j = range; j >= 0; --j){ 80 | s1$1[i2$1 + j | 0] = s1$1[i1$1 + j | 0]; 81 | } 82 | return /* () */0; 83 | } else if (i1$1 > i2$1) { 84 | var range_a$1 = (s1$1.length - i1$1 | 0) - 1 | 0; 85 | var range_b$1 = len$1 - 1 | 0; 86 | var range$1 = range_a$1 > range_b$1 ? range_b$1 : range_a$1; 87 | for(var k = 0; k <= range$1; ++k){ 88 | s1$1[i2$1 + k | 0] = s1$1[i1$1 + k | 0]; 89 | } 90 | return /* () */0; 91 | } else { 92 | return 0; 93 | } 94 | } else { 95 | var off1 = s1.length - i1 | 0; 96 | if (len <= off1) { 97 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 98 | s2[i2 + i | 0] = s1[i1 + i | 0]; 99 | } 100 | return /* () */0; 101 | } else { 102 | for(var i$1 = 0 ,i_finish$1 = off1 - 1 | 0; i$1 <= i_finish$1; ++i$1){ 103 | s2[i2 + i$1 | 0] = s1[i1 + i$1 | 0]; 104 | } 105 | for(var i$2 = off1 ,i_finish$2 = len - 1 | 0; i$2 <= i_finish$2; ++i$2){ 106 | s2[i2 + i$2 | 0] = /* "\000" */0; 107 | } 108 | return /* () */0; 109 | } 110 | } 111 | } else { 112 | return 0; 113 | } 114 | } 115 | 116 | function bytes_of_string(s) { 117 | var len = s.length; 118 | var res = new Array(len); 119 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 120 | res[i] = s.charCodeAt(i); 121 | } 122 | return res; 123 | } 124 | 125 | function bytes_to_string(a) { 126 | var bytes = a; 127 | var i = 0; 128 | var len = a.length; 129 | var s = ""; 130 | var s_len = len; 131 | if (i === 0 && len <= 4096 && len === bytes.length) { 132 | return String.fromCharCode.apply(null, bytes); 133 | } else { 134 | var offset = 0; 135 | while(s_len > 0) { 136 | var next = s_len < 1024 ? s_len : 1024; 137 | var tmp_bytes = new Array(next); 138 | caml_blit_bytes(bytes, offset, tmp_bytes, 0, next); 139 | s = s + String.fromCharCode.apply(null, tmp_bytes); 140 | s_len = s_len - next | 0; 141 | offset = offset + next | 0; 142 | }; 143 | return s; 144 | } 145 | } 146 | 147 | function caml_string_of_char_array(chars) { 148 | var len = chars.length; 149 | var bytes = new Array(len); 150 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 151 | bytes[i] = chars[i]; 152 | } 153 | return bytes_to_string(bytes); 154 | } 155 | 156 | function caml_is_printable(c) { 157 | if (c > 31) { 158 | return c < 127; 159 | } else { 160 | return false; 161 | } 162 | } 163 | 164 | function caml_string_get16(s, i) { 165 | return s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0; 166 | } 167 | 168 | function caml_string_get32(s, i) { 169 | return ((s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0) + (s.charCodeAt(i + 2 | 0) << 16) | 0) + (s.charCodeAt(i + 3 | 0) << 24) | 0; 170 | } 171 | 172 | function get(s, i) { 173 | if (i < 0 || i >= s.length) { 174 | throw [ 175 | Caml_builtin_exceptions.invalid_argument, 176 | "index out of bounds" 177 | ]; 178 | } else { 179 | return s.charCodeAt(i); 180 | } 181 | } 182 | 183 | export { 184 | bytes_of_string , 185 | bytes_to_string , 186 | caml_is_printable , 187 | caml_string_of_char_array , 188 | caml_string_get , 189 | caml_create_string , 190 | caml_fill_string , 191 | caml_blit_string , 192 | caml_blit_bytes , 193 | caml_string_get16 , 194 | caml_string_get32 , 195 | string_of_char , 196 | get , 197 | 198 | } 199 | /* No side effect */ 200 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_sys.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 4 | 5 | function caml_sys_getenv(s) { 6 | var match = typeof (process) === "undefined" ? undefined : (process); 7 | if (match !== undefined) { 8 | var match$1 = match.env[s]; 9 | if (match$1 !== undefined) { 10 | return match$1; 11 | } else { 12 | throw Caml_builtin_exceptions.not_found; 13 | } 14 | } else { 15 | throw Caml_builtin_exceptions.not_found; 16 | } 17 | } 18 | 19 | function caml_sys_time() { 20 | var match = typeof (process) === "undefined" ? undefined : (process); 21 | if (match !== undefined) { 22 | return match.uptime(); 23 | } else { 24 | return -1; 25 | } 26 | } 27 | 28 | function caml_sys_random_seed() { 29 | return /* array */[((Date.now() | 0) ^ 4294967295) * Math.random() | 0]; 30 | } 31 | 32 | function caml_sys_system_command() { 33 | return 127; 34 | } 35 | 36 | function caml_sys_getcwd() { 37 | var match = typeof (process) === "undefined" ? undefined : (process); 38 | if (match !== undefined) { 39 | return match.cwd(); 40 | } else { 41 | return "/"; 42 | } 43 | } 44 | 45 | function caml_sys_get_argv() { 46 | var match = typeof (process) === "undefined" ? undefined : (process); 47 | if (match !== undefined) { 48 | if (match.argv == null) { 49 | return /* tuple */[ 50 | "", 51 | /* array */[""] 52 | ]; 53 | } else { 54 | return /* tuple */[ 55 | match.argv[0], 56 | match.argv 57 | ]; 58 | } 59 | } else { 60 | return /* tuple */[ 61 | "", 62 | /* array */[""] 63 | ]; 64 | } 65 | } 66 | 67 | function caml_sys_exit(exit_code) { 68 | var match = typeof (process) === "undefined" ? undefined : (process); 69 | if (match !== undefined) { 70 | return match.exit(exit_code); 71 | } else { 72 | return /* () */0; 73 | } 74 | } 75 | 76 | function caml_sys_is_directory() { 77 | throw [ 78 | Caml_builtin_exceptions.failure, 79 | "caml_sys_is_directory not implemented" 80 | ]; 81 | } 82 | 83 | function caml_sys_file_exists() { 84 | throw [ 85 | Caml_builtin_exceptions.failure, 86 | "caml_sys_file_exists not implemented" 87 | ]; 88 | } 89 | 90 | export { 91 | caml_sys_getenv , 92 | caml_sys_time , 93 | caml_sys_random_seed , 94 | caml_sys_system_command , 95 | caml_sys_getcwd , 96 | caml_sys_get_argv , 97 | caml_sys_exit , 98 | caml_sys_is_directory , 99 | caml_sys_file_exists , 100 | 101 | } 102 | /* No side effect */ 103 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_utils.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var repeat = ( (String.prototype.repeat && function (count,self){return self.repeat(count)}) || 5 | function(count , self) { 6 | if (self.length == 0 || count == 0) { 7 | return ''; 8 | } 9 | // Ensuring count is a 31-bit integer allows us to heavily optimize the 10 | // main part. But anyway, most current (August 2014) browsers can't handle 11 | // strings 1 << 28 chars or longer, so: 12 | if (self.length * count >= 1 << 28) { 13 | throw new RangeError('repeat count must not overflow maximum string size'); 14 | } 15 | var rpt = ''; 16 | for (;;) { 17 | if ((count & 1) == 1) { 18 | rpt += self; 19 | } 20 | count >>>= 1; 21 | if (count == 0) { 22 | break; 23 | } 24 | self += self; 25 | } 26 | return rpt; 27 | } 28 | ); 29 | 30 | export { 31 | repeat , 32 | 33 | } 34 | /* repeat Not a pure module */ 35 | -------------------------------------------------------------------------------- /runtime/stdlib/caml_weak.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_obj from "stdlib/caml_obj.js"; 4 | import * as Caml_array from "stdlib/caml_array.js"; 5 | import * as Js_primitive from "stdlib/js_primitive.js"; 6 | 7 | function caml_weak_create(n) { 8 | return new Array(n); 9 | } 10 | 11 | function caml_weak_set(xs, i, v) { 12 | if (v) { 13 | xs[i] = v[0]; 14 | return /* () */0; 15 | } else { 16 | return /* () */0; 17 | } 18 | } 19 | 20 | function caml_weak_get(xs, i) { 21 | return Js_primitive.undefined_to_opt(xs[i]); 22 | } 23 | 24 | function caml_weak_get_copy(xs, i) { 25 | var match = xs[i]; 26 | if (match !== undefined) { 27 | return /* Some */[Caml_obj.caml_obj_dup(match)]; 28 | } else { 29 | return /* None */0; 30 | } 31 | } 32 | 33 | function caml_weak_check(xs, i) { 34 | return xs[i] !== undefined; 35 | } 36 | 37 | var caml_weak_blit = Caml_array.caml_array_blit; 38 | 39 | export { 40 | caml_weak_create , 41 | caml_weak_set , 42 | caml_weak_get , 43 | caml_weak_get_copy , 44 | caml_weak_check , 45 | caml_weak_blit , 46 | 47 | } 48 | /* No side effect */ 49 | -------------------------------------------------------------------------------- /runtime/stdlib/camlinternalLazy.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Obj from "stdlib/obj.js"; 4 | import * as Curry from "stdlib/curry.js"; 5 | import * as Caml_exceptions from "stdlib/caml_exceptions.js"; 6 | 7 | var Undefined = Caml_exceptions.create("CamlinternalLazy.Undefined"); 8 | 9 | function raise_undefined() { 10 | throw Undefined; 11 | } 12 | 13 | function force_lazy_block(blk) { 14 | var closure = blk[0]; 15 | blk[0] = raise_undefined; 16 | try { 17 | var result = Curry._1(closure, /* () */0); 18 | blk[0] = result; 19 | blk.tag = Obj.forward_tag; 20 | return result; 21 | } 22 | catch (e){ 23 | blk[0] = (function () { 24 | throw e; 25 | }); 26 | throw e; 27 | } 28 | } 29 | 30 | function force_val_lazy_block(blk) { 31 | var closure = blk[0]; 32 | blk[0] = raise_undefined; 33 | var result = Curry._1(closure, /* () */0); 34 | blk[0] = result; 35 | blk.tag = Obj.forward_tag; 36 | return result; 37 | } 38 | 39 | function force(lzv) { 40 | var t = lzv.tag | 0; 41 | if (t === Obj.forward_tag) { 42 | return lzv[0]; 43 | } else if (t !== Obj.lazy_tag) { 44 | return lzv; 45 | } else { 46 | return force_lazy_block(lzv); 47 | } 48 | } 49 | 50 | function force_val(lzv) { 51 | var t = lzv.tag | 0; 52 | if (t === Obj.forward_tag) { 53 | return lzv[0]; 54 | } else if (t !== Obj.lazy_tag) { 55 | return lzv; 56 | } else { 57 | return force_val_lazy_block(lzv); 58 | } 59 | } 60 | 61 | export { 62 | Undefined , 63 | force_lazy_block , 64 | force_val_lazy_block , 65 | force , 66 | force_val , 67 | 68 | } 69 | /* No side effect */ 70 | -------------------------------------------------------------------------------- /runtime/stdlib/camlinternalMod.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/char.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_string from "stdlib/caml_string.js"; 4 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 5 | 6 | function chr(n) { 7 | if (n < 0 || n > 255) { 8 | throw [ 9 | Caml_builtin_exceptions.invalid_argument, 10 | "Char.chr" 11 | ]; 12 | } else { 13 | return n; 14 | } 15 | } 16 | 17 | function escaped(c) { 18 | var exit = 0; 19 | if (c >= 40) { 20 | if (c !== 92) { 21 | exit = c >= 127 ? 1 : 2; 22 | } else { 23 | return "\\\\"; 24 | } 25 | } else if (c >= 32) { 26 | if (c >= 39) { 27 | return "\\'"; 28 | } else { 29 | exit = 2; 30 | } 31 | } else if (c >= 14) { 32 | exit = 1; 33 | } else { 34 | switch (c) { 35 | case 8 : 36 | return "\\b"; 37 | case 9 : 38 | return "\\t"; 39 | case 10 : 40 | return "\\n"; 41 | case 0 : 42 | case 1 : 43 | case 2 : 44 | case 3 : 45 | case 4 : 46 | case 5 : 47 | case 6 : 48 | case 7 : 49 | case 11 : 50 | case 12 : 51 | exit = 1; 52 | break; 53 | case 13 : 54 | return "\\r"; 55 | 56 | } 57 | } 58 | switch (exit) { 59 | case 1 : 60 | var s = Caml_string.caml_create_string(4); 61 | s[0] = /* "\\" */92; 62 | s[1] = 48 + (c / 100 | 0) | 0; 63 | s[2] = 48 + (c / 10 | 0) % 10 | 0; 64 | s[3] = 48 + c % 10 | 0; 65 | return Caml_string.bytes_to_string(s); 66 | case 2 : 67 | var s$1 = Caml_string.caml_create_string(1); 68 | s$1[0] = c; 69 | return Caml_string.bytes_to_string(s$1); 70 | 71 | } 72 | } 73 | 74 | function lowercase(c) { 75 | if (c >= /* "A" */65 && c <= /* "Z" */90 || c >= /* "\192" */192 && c <= /* "\214" */214 || c >= /* "\216" */216 && c <= /* "\222" */222) { 76 | return c + 32 | 0; 77 | } else { 78 | return c; 79 | } 80 | } 81 | 82 | function uppercase(c) { 83 | if (c >= /* "a" */97 && c <= /* "z" */122 || c >= /* "\224" */224 && c <= /* "\246" */246 || c >= /* "\248" */248 && c <= /* "\254" */254) { 84 | return c - 32 | 0; 85 | } else { 86 | return c; 87 | } 88 | } 89 | 90 | function compare(c1, c2) { 91 | return c1 - c2 | 0; 92 | } 93 | 94 | export { 95 | chr , 96 | escaped , 97 | lowercase , 98 | uppercase , 99 | compare , 100 | 101 | } 102 | /* No side effect */ 103 | -------------------------------------------------------------------------------- /runtime/stdlib/complex.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var one = /* record */[ 5 | /* re */1.0, 6 | /* im */0.0 7 | ]; 8 | 9 | function add(x, y) { 10 | return /* record */[ 11 | /* re */x[/* re */0] + y[/* re */0], 12 | /* im */x[/* im */1] + y[/* im */1] 13 | ]; 14 | } 15 | 16 | function sub(x, y) { 17 | return /* record */[ 18 | /* re */x[/* re */0] - y[/* re */0], 19 | /* im */x[/* im */1] - y[/* im */1] 20 | ]; 21 | } 22 | 23 | function neg(x) { 24 | return /* record */[ 25 | /* re */-x[/* re */0], 26 | /* im */-x[/* im */1] 27 | ]; 28 | } 29 | 30 | function conj(x) { 31 | return /* record */[ 32 | /* re */x[/* re */0], 33 | /* im */-x[/* im */1] 34 | ]; 35 | } 36 | 37 | function mul(x, y) { 38 | return /* record */[ 39 | /* re */x[/* re */0] * y[/* re */0] - x[/* im */1] * y[/* im */1], 40 | /* im */x[/* re */0] * y[/* im */1] + x[/* im */1] * y[/* re */0] 41 | ]; 42 | } 43 | 44 | function div(x, y) { 45 | if (Math.abs(y[/* re */0]) >= Math.abs(y[/* im */1])) { 46 | var r = y[/* im */1] / y[/* re */0]; 47 | var d = y[/* re */0] + r * y[/* im */1]; 48 | return /* record */[ 49 | /* re */(x[/* re */0] + r * x[/* im */1]) / d, 50 | /* im */(x[/* im */1] - r * x[/* re */0]) / d 51 | ]; 52 | } else { 53 | var r$1 = y[/* re */0] / y[/* im */1]; 54 | var d$1 = y[/* im */1] + r$1 * y[/* re */0]; 55 | return /* record */[ 56 | /* re */(r$1 * x[/* re */0] + x[/* im */1]) / d$1, 57 | /* im */(r$1 * x[/* im */1] - x[/* re */0]) / d$1 58 | ]; 59 | } 60 | } 61 | 62 | function inv(x) { 63 | return div(one, x); 64 | } 65 | 66 | function norm2(x) { 67 | return x[/* re */0] * x[/* re */0] + x[/* im */1] * x[/* im */1]; 68 | } 69 | 70 | function norm(x) { 71 | var r = Math.abs(x[/* re */0]); 72 | var i = Math.abs(x[/* im */1]); 73 | if (r === 0.0) { 74 | return i; 75 | } else if (i === 0.0) { 76 | return r; 77 | } else if (r >= i) { 78 | var q = i / r; 79 | return r * Math.sqrt(1.0 + q * q); 80 | } else { 81 | var q$1 = r / i; 82 | return i * Math.sqrt(1.0 + q$1 * q$1); 83 | } 84 | } 85 | 86 | function arg(x) { 87 | return Math.atan2(x[/* im */1], x[/* re */0]); 88 | } 89 | 90 | function polar(n, a) { 91 | return /* record */[ 92 | /* re */Math.cos(a) * n, 93 | /* im */Math.sin(a) * n 94 | ]; 95 | } 96 | 97 | function sqrt(x) { 98 | if (x[/* re */0] === 0.0 && x[/* im */1] === 0.0) { 99 | return /* record */[ 100 | /* re */0.0, 101 | /* im */0.0 102 | ]; 103 | } else { 104 | var r = Math.abs(x[/* re */0]); 105 | var i = Math.abs(x[/* im */1]); 106 | var w; 107 | if (r >= i) { 108 | var q = i / r; 109 | w = Math.sqrt(r) * Math.sqrt(0.5 * (1.0 + Math.sqrt(1.0 + q * q))); 110 | } else { 111 | var q$1 = r / i; 112 | w = Math.sqrt(i) * Math.sqrt(0.5 * (q$1 + Math.sqrt(1.0 + q$1 * q$1))); 113 | } 114 | if (x[/* re */0] >= 0.0) { 115 | return /* record */[ 116 | /* re */w, 117 | /* im */0.5 * x[/* im */1] / w 118 | ]; 119 | } else { 120 | return /* record */[ 121 | /* re */0.5 * i / w, 122 | /* im */x[/* im */1] >= 0.0 ? w : -w 123 | ]; 124 | } 125 | } 126 | } 127 | 128 | function exp(x) { 129 | var e = Math.exp(x[/* re */0]); 130 | return /* record */[ 131 | /* re */e * Math.cos(x[/* im */1]), 132 | /* im */e * Math.sin(x[/* im */1]) 133 | ]; 134 | } 135 | 136 | function log(x) { 137 | return /* record */[ 138 | /* re */Math.log(norm(x)), 139 | /* im */Math.atan2(x[/* im */1], x[/* re */0]) 140 | ]; 141 | } 142 | 143 | function pow(x, y) { 144 | return exp(mul(y, log(x))); 145 | } 146 | 147 | var zero = /* record */[ 148 | /* re */0.0, 149 | /* im */0.0 150 | ]; 151 | 152 | var i = /* record */[ 153 | /* re */0.0, 154 | /* im */1.0 155 | ]; 156 | 157 | export { 158 | zero , 159 | one , 160 | i , 161 | neg , 162 | conj , 163 | add , 164 | sub , 165 | mul , 166 | inv , 167 | div , 168 | sqrt , 169 | norm2 , 170 | norm , 171 | arg , 172 | polar , 173 | exp , 174 | log , 175 | pow , 176 | 177 | } 178 | /* No side effect */ 179 | -------------------------------------------------------------------------------- /runtime/stdlib/digest.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Char from "stdlib/char.js"; 4 | import * as $$String from "stdlib/string.js"; 5 | import * as Caml_md5 from "stdlib/caml_md5.js"; 6 | import * as Pervasives from "stdlib/pervasives.js"; 7 | import * as Caml_string from "stdlib/caml_string.js"; 8 | import * as Caml_missing_polyfill from "stdlib/caml_missing_polyfill.js"; 9 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 10 | 11 | function string(str) { 12 | return Caml_md5.caml_md5_string(str, 0, str.length); 13 | } 14 | 15 | function bytes(b) { 16 | return string(Caml_string.bytes_to_string(b)); 17 | } 18 | 19 | function substring(str, ofs, len) { 20 | if (ofs < 0 || len < 0 || ofs > (str.length - len | 0)) { 21 | throw [ 22 | Caml_builtin_exceptions.invalid_argument, 23 | "Digest.substring" 24 | ]; 25 | } else { 26 | return Caml_md5.caml_md5_string(str, ofs, len); 27 | } 28 | } 29 | 30 | function subbytes(b, ofs, len) { 31 | return substring(Caml_string.bytes_to_string(b), ofs, len); 32 | } 33 | 34 | function file(filename) { 35 | Pervasives.open_in_bin(filename); 36 | var exit = 0; 37 | var d; 38 | try { 39 | d = Caml_missing_polyfill.not_implemented("caml_md5_chan"); 40 | exit = 1; 41 | } 42 | catch (e){ 43 | Caml_missing_polyfill.not_implemented("caml_ml_close_channel"); 44 | throw e; 45 | } 46 | if (exit === 1) { 47 | Caml_missing_polyfill.not_implemented("caml_ml_close_channel"); 48 | return d; 49 | } 50 | 51 | } 52 | 53 | var output = Pervasives.output_string; 54 | 55 | function input(chan) { 56 | return Pervasives.really_input_string(chan, 16); 57 | } 58 | 59 | function char_hex(n) { 60 | return n + ( 61 | n < 10 ? /* "0" */48 : 87 62 | ) | 0; 63 | } 64 | 65 | function to_hex(d) { 66 | var result = Caml_string.caml_create_string(32); 67 | for(var i = 0; i <= 15; ++i){ 68 | var x = Caml_string.get(d, i); 69 | result[(i << 1)] = char_hex((x >>> 4)); 70 | result[(i << 1) + 1 | 0] = char_hex(x & 15); 71 | } 72 | return Caml_string.bytes_to_string(result); 73 | } 74 | 75 | function from_hex(s) { 76 | if (s.length !== 32) { 77 | throw [ 78 | Caml_builtin_exceptions.invalid_argument, 79 | "Digest.from_hex" 80 | ]; 81 | } 82 | var digit = function (c) { 83 | if (c >= 65) { 84 | if (c >= 97) { 85 | if (c >= 103) { 86 | throw [ 87 | Caml_builtin_exceptions.invalid_argument, 88 | "Digest.from_hex" 89 | ]; 90 | } else { 91 | return (c - /* "a" */97 | 0) + 10 | 0; 92 | } 93 | } else if (c >= 71) { 94 | throw [ 95 | Caml_builtin_exceptions.invalid_argument, 96 | "Digest.from_hex" 97 | ]; 98 | } else { 99 | return (c - /* "A" */65 | 0) + 10 | 0; 100 | } 101 | } else if (c > 57 || c < 48) { 102 | throw [ 103 | Caml_builtin_exceptions.invalid_argument, 104 | "Digest.from_hex" 105 | ]; 106 | } else { 107 | return c - /* "0" */48 | 0; 108 | } 109 | }; 110 | var $$byte = function (i) { 111 | return (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; 112 | }; 113 | var result = Caml_string.caml_create_string(16); 114 | for(var i = 0; i <= 15; ++i){ 115 | result[i] = Char.chr($$byte((i << 1))); 116 | } 117 | return Caml_string.bytes_to_string(result); 118 | } 119 | 120 | var compare = $$String.compare; 121 | 122 | export { 123 | compare , 124 | string , 125 | bytes , 126 | substring , 127 | subbytes , 128 | file , 129 | output , 130 | input , 131 | to_hex , 132 | from_hex , 133 | 134 | } 135 | /* No side effect */ 136 | -------------------------------------------------------------------------------- /runtime/stdlib/int32.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_format from "stdlib/caml_format.js"; 4 | import * as Caml_primitive from "stdlib/caml_primitive.js"; 5 | 6 | function succ(n) { 7 | return n + 1 | 0; 8 | } 9 | 10 | function pred(n) { 11 | return n - 1 | 0; 12 | } 13 | 14 | function abs(n) { 15 | if (n >= 0) { 16 | return n; 17 | } else { 18 | return -n | 0; 19 | } 20 | } 21 | 22 | function lognot(n) { 23 | return n ^ -1; 24 | } 25 | 26 | function to_string(n) { 27 | return Caml_format.caml_int32_format("%d", n); 28 | } 29 | 30 | var compare = Caml_primitive.caml_int32_compare; 31 | 32 | var zero = 0; 33 | 34 | var one = 1; 35 | 36 | var minus_one = -1; 37 | 38 | var max_int = 2147483647; 39 | 40 | var min_int = -2147483648; 41 | 42 | export { 43 | zero , 44 | one , 45 | minus_one , 46 | succ , 47 | pred , 48 | abs , 49 | max_int , 50 | min_int , 51 | lognot , 52 | to_string , 53 | compare , 54 | 55 | } 56 | /* No side effect */ 57 | -------------------------------------------------------------------------------- /runtime/stdlib/int64.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_int64 from "stdlib/caml_int64.js"; 4 | import * as Caml_format from "stdlib/caml_format.js"; 5 | 6 | function succ(n) { 7 | return Caml_int64.add(n, /* int64 */[ 8 | /* hi */0, 9 | /* lo */1 10 | ]); 11 | } 12 | 13 | function pred(n) { 14 | return Caml_int64.sub(n, /* int64 */[ 15 | /* hi */0, 16 | /* lo */1 17 | ]); 18 | } 19 | 20 | function abs(n) { 21 | if (Caml_int64.ge(n, /* int64 */[ 22 | /* hi */0, 23 | /* lo */0 24 | ])) { 25 | return n; 26 | } else { 27 | return Caml_int64.neg(n); 28 | } 29 | } 30 | 31 | function lognot(n) { 32 | return Caml_int64.xor(n, /* int64 */[ 33 | /* hi */-1, 34 | /* lo */4294967295 35 | ]); 36 | } 37 | 38 | function to_string(n) { 39 | return Caml_format.caml_int64_format("%d", n); 40 | } 41 | 42 | var compare = Caml_int64.compare; 43 | 44 | var zero = /* int64 */[ 45 | /* hi */0, 46 | /* lo */0 47 | ]; 48 | 49 | var one = /* int64 */[ 50 | /* hi */0, 51 | /* lo */1 52 | ]; 53 | 54 | var minus_one = /* int64 */[ 55 | /* hi */-1, 56 | /* lo */4294967295 57 | ]; 58 | 59 | var max_int = /* int64 */[ 60 | /* hi */2147483647, 61 | /* lo */4294967295 62 | ]; 63 | 64 | var min_int = /* int64 */[ 65 | /* hi */-2147483648, 66 | /* lo */0 67 | ]; 68 | 69 | export { 70 | zero , 71 | one , 72 | minus_one , 73 | succ , 74 | pred , 75 | abs , 76 | max_int , 77 | min_int , 78 | lognot , 79 | to_string , 80 | compare , 81 | 82 | } 83 | /* No side effect */ 84 | -------------------------------------------------------------------------------- /runtime/stdlib/js.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var MapperRt = 0; 5 | 6 | var Internal = 0; 7 | 8 | var Null = 0; 9 | 10 | var Undefined = 0; 11 | 12 | var Nullable = 0; 13 | 14 | var Null_undefined = 0; 15 | 16 | var Exn = 0; 17 | 18 | var $$Array = 0; 19 | 20 | var $$String = 0; 21 | 22 | var Re = 0; 23 | 24 | var Promise = 0; 25 | 26 | var $$Date = 0; 27 | 28 | var Dict = 0; 29 | 30 | var Global = 0; 31 | 32 | var Json = 0; 33 | 34 | var $$Math = 0; 35 | 36 | var Obj = 0; 37 | 38 | var Typed_array = 0; 39 | 40 | var Types = 0; 41 | 42 | var Float = 0; 43 | 44 | var Int = 0; 45 | 46 | var Option = 0; 47 | 48 | var Result = 0; 49 | 50 | var List = 0; 51 | 52 | var Vector = 0; 53 | 54 | var Console = 0; 55 | 56 | export { 57 | MapperRt , 58 | Internal , 59 | Null , 60 | Undefined , 61 | Nullable , 62 | Null_undefined , 63 | Exn , 64 | $$Array , 65 | $$String , 66 | Re , 67 | Promise , 68 | $$Date , 69 | Dict , 70 | Global , 71 | Json , 72 | $$Math , 73 | Obj , 74 | Typed_array , 75 | Types , 76 | Float , 77 | Int , 78 | Option , 79 | Result , 80 | List , 81 | Vector , 82 | Console , 83 | 84 | } 85 | /* No side effect */ 86 | -------------------------------------------------------------------------------- /runtime/stdlib/js_array.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_cast.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_console.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_date.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_dict.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var unsafeDeleteKey = ( 5 | function(dict,key){ 6 | delete dict[key]; 7 | return 0 8 | } 9 | ); 10 | 11 | function entries(dict) { 12 | var keys = Object.keys(dict); 13 | var l = keys.length; 14 | var values = new Array(l); 15 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 16 | var key = keys[i]; 17 | values[i] = /* tuple */[ 18 | key, 19 | dict[key] 20 | ]; 21 | } 22 | return values; 23 | } 24 | 25 | function values(dict) { 26 | var keys = Object.keys(dict); 27 | var l = keys.length; 28 | var values$1 = new Array(l); 29 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 30 | values$1[i] = dict[keys[i]]; 31 | } 32 | return values$1; 33 | } 34 | 35 | function fromList(entries) { 36 | var dict = { }; 37 | var _param = entries; 38 | while(true) { 39 | var param = _param; 40 | if (param) { 41 | var match = param[0]; 42 | dict[match[0]] = match[1]; 43 | _param = param[1]; 44 | continue ; 45 | } else { 46 | return dict; 47 | } 48 | }; 49 | } 50 | 51 | function fromArray(entries) { 52 | var dict = { }; 53 | var l = entries.length; 54 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 55 | var match = entries[i]; 56 | dict[match[0]] = match[1]; 57 | } 58 | return dict; 59 | } 60 | 61 | function map(f, source) { 62 | var target = { }; 63 | var keys = Object.keys(source); 64 | var l = keys.length; 65 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 66 | var key = keys[i]; 67 | target[key] = f(source[key]); 68 | } 69 | return target; 70 | } 71 | 72 | export { 73 | unsafeDeleteKey , 74 | entries , 75 | values , 76 | fromList , 77 | fromArray , 78 | map , 79 | 80 | } 81 | /* unsafeDeleteKey Not a pure module */ 82 | -------------------------------------------------------------------------------- /runtime/stdlib/js_exn.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_exceptions from "stdlib/caml_exceptions.js"; 4 | 5 | var $$Error = Caml_exceptions.create("Js_exn.Error"); 6 | 7 | function internalToOCamlException(e) { 8 | if (Caml_exceptions.isCamlExceptionOrOpenVariant(e)) { 9 | return e; 10 | } else { 11 | return [ 12 | $$Error, 13 | e 14 | ]; 15 | } 16 | } 17 | 18 | function raiseError(str) { 19 | throw new Error(str); 20 | } 21 | 22 | function raiseEvalError(str) { 23 | throw new EvalError(str); 24 | } 25 | 26 | function raiseRangeError(str) { 27 | throw new RangeError(str); 28 | } 29 | 30 | function raiseReferenceError(str) { 31 | throw new ReferenceError(str); 32 | } 33 | 34 | function raiseSyntaxError(str) { 35 | throw new SyntaxError(str); 36 | } 37 | 38 | function raiseTypeError(str) { 39 | throw new TypeError(str); 40 | } 41 | 42 | function raiseUriError(str) { 43 | throw new URIError(str); 44 | } 45 | 46 | export { 47 | $$Error , 48 | internalToOCamlException , 49 | raiseError , 50 | raiseEvalError , 51 | raiseRangeError , 52 | raiseReferenceError , 53 | raiseSyntaxError , 54 | raiseTypeError , 55 | raiseUriError , 56 | 57 | } 58 | /* No side effect */ 59 | -------------------------------------------------------------------------------- /runtime/stdlib/js_float.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_global.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_int.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function equal(x, y) { 5 | return x === y; 6 | } 7 | 8 | var max = 2147483647; 9 | 10 | var min = -2147483648; 11 | 12 | export { 13 | equal , 14 | max , 15 | min , 16 | 17 | } 18 | /* No side effect */ 19 | -------------------------------------------------------------------------------- /runtime/stdlib/js_int64.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_internal.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_json.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Block from "stdlib/block.js"; 4 | 5 | function classify(x) { 6 | var ty = typeof x; 7 | if (ty === "string") { 8 | return /* JSONString */Block.__(0, [x]); 9 | } else if (ty === "number") { 10 | return /* JSONNumber */Block.__(1, [x]); 11 | } else if (ty === "boolean") { 12 | if (x === true) { 13 | return /* JSONTrue */1; 14 | } else { 15 | return /* JSONFalse */0; 16 | } 17 | } else if (x === null) { 18 | return /* JSONNull */2; 19 | } else if (Array.isArray(x)) { 20 | return /* JSONArray */Block.__(3, [x]); 21 | } else { 22 | return /* JSONObject */Block.__(2, [x]); 23 | } 24 | } 25 | 26 | function test(x, v) { 27 | switch (v) { 28 | case 0 : 29 | return typeof x === "string"; 30 | case 1 : 31 | return typeof x === "number"; 32 | case 2 : 33 | if (x !== null && typeof x === "object") { 34 | return !Array.isArray(x); 35 | } else { 36 | return false; 37 | } 38 | case 3 : 39 | return Array.isArray(x); 40 | case 4 : 41 | return typeof x === "boolean"; 42 | case 5 : 43 | return x === null; 44 | 45 | } 46 | } 47 | 48 | function decodeString(json) { 49 | if (typeof json === "string") { 50 | return /* Some */[json]; 51 | } else { 52 | return /* None */0; 53 | } 54 | } 55 | 56 | function decodeNumber(json) { 57 | if (typeof json === "number") { 58 | return /* Some */[json]; 59 | } else { 60 | return /* None */0; 61 | } 62 | } 63 | 64 | function decodeObject(json) { 65 | if (typeof json === "object" && !Array.isArray(json) && json !== null) { 66 | return /* Some */[json]; 67 | } else { 68 | return /* None */0; 69 | } 70 | } 71 | 72 | function decodeArray(json) { 73 | if (Array.isArray(json)) { 74 | return /* Some */[json]; 75 | } else { 76 | return /* None */0; 77 | } 78 | } 79 | 80 | function decodeBoolean(json) { 81 | if (typeof json === "boolean") { 82 | return /* Some */[json]; 83 | } else { 84 | return /* None */0; 85 | } 86 | } 87 | 88 | function decodeNull(json) { 89 | if (json === null) { 90 | return /* Some */[null]; 91 | } else { 92 | return /* None */0; 93 | } 94 | } 95 | 96 | export { 97 | classify , 98 | test , 99 | decodeString , 100 | decodeNumber , 101 | decodeObject , 102 | decodeArray , 103 | decodeBoolean , 104 | decodeNull , 105 | 106 | } 107 | /* No side effect */ 108 | -------------------------------------------------------------------------------- /runtime/stdlib/js_mapperRt.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function binarySearch(upper, id, array) { 5 | var _lower = 0; 6 | var _upper = upper; 7 | var xs = array; 8 | var k = id; 9 | while(true) { 10 | var upper$1 = _upper; 11 | var lower = _lower; 12 | if (lower >= upper$1) { 13 | throw new Error("File \"js_mapperRt.ml\", line 35, characters 4-10"); 14 | } 15 | var mid = (lower + upper$1 | 0) / 2 | 0; 16 | var match = xs[mid]; 17 | var i = match[0]; 18 | if (i === k) { 19 | return match[1]; 20 | } else if (i < k) { 21 | _lower = mid + 1 | 0; 22 | continue ; 23 | } else { 24 | _upper = mid; 25 | continue ; 26 | } 27 | }; 28 | } 29 | 30 | function revSearch(len, array, x) { 31 | var _i = 0; 32 | var len$1 = len; 33 | var xs = array; 34 | var k = x; 35 | while(true) { 36 | var i = _i; 37 | if (i === len$1) { 38 | return /* None */0; 39 | } else { 40 | var match = xs[i]; 41 | if (match[1] === k) { 42 | return /* Some */[match[0]]; 43 | } else { 44 | _i = i + 1 | 0; 45 | continue ; 46 | } 47 | } 48 | }; 49 | } 50 | 51 | function revSearchAssert(len, array, x) { 52 | var len$1 = len; 53 | var _i = 0; 54 | var xs = array; 55 | var k = x; 56 | while(true) { 57 | var i = _i; 58 | if (i >= len$1) { 59 | throw new Error("File \"js_mapperRt.ml\", line 64, characters 4-10"); 60 | } 61 | var match = xs[i]; 62 | if (match[1] === k) { 63 | return match[0]; 64 | } else { 65 | _i = i + 1 | 0; 66 | continue ; 67 | } 68 | }; 69 | } 70 | 71 | function toInt(i, xs) { 72 | return xs[i]; 73 | } 74 | 75 | function fromInt(len, xs, $$enum) { 76 | var $$enum$1 = $$enum; 77 | var _i = 0; 78 | var len$1 = len; 79 | var xs$1 = xs; 80 | while(true) { 81 | var i = _i; 82 | if (i === len$1) { 83 | return /* None */0; 84 | } else { 85 | var k = xs$1[i]; 86 | if (k === $$enum$1) { 87 | return /* Some */[i]; 88 | } else { 89 | _i = i + 1 | 0; 90 | continue ; 91 | } 92 | } 93 | }; 94 | } 95 | 96 | function fromIntAssert(len, xs, $$enum) { 97 | var len$1 = len; 98 | var $$enum$1 = $$enum; 99 | var _i = 0; 100 | var xs$1 = xs; 101 | while(true) { 102 | var i = _i; 103 | if (i >= len$1) { 104 | throw new Error("File \"js_mapperRt.ml\", line 88, characters 4-10"); 105 | } 106 | var k = xs$1[i]; 107 | if (k === $$enum$1) { 108 | return i; 109 | } else { 110 | _i = i + 1 | 0; 111 | continue ; 112 | } 113 | }; 114 | } 115 | 116 | export { 117 | binarySearch , 118 | revSearch , 119 | revSearchAssert , 120 | toInt , 121 | fromInt , 122 | fromIntAssert , 123 | 124 | } 125 | /* No side effect */ 126 | -------------------------------------------------------------------------------- /runtime/stdlib/js_math.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Js_int from "stdlib/js_int.js"; 4 | 5 | function unsafe_ceil(prim) { 6 | return Math.ceil(prim); 7 | } 8 | 9 | function ceil_int(f) { 10 | if (f > Js_int.max) { 11 | return Js_int.max; 12 | } else if (f < Js_int.min) { 13 | return Js_int.min; 14 | } else { 15 | return Math.ceil(f); 16 | } 17 | } 18 | 19 | function unsafe_floor(prim) { 20 | return Math.floor(prim); 21 | } 22 | 23 | function floor_int(f) { 24 | if (f > Js_int.max) { 25 | return Js_int.max; 26 | } else if (f < Js_int.min) { 27 | return Js_int.min; 28 | } else { 29 | return Math.floor(f); 30 | } 31 | } 32 | 33 | function random_int(min, max) { 34 | return floor_int(Math.random() * (max - min | 0)) + min | 0; 35 | } 36 | 37 | var ceil = ceil_int; 38 | 39 | var floor = floor_int; 40 | 41 | export { 42 | unsafe_ceil , 43 | ceil_int , 44 | ceil , 45 | unsafe_floor , 46 | floor_int , 47 | floor , 48 | random_int , 49 | 50 | } 51 | /* No side effect */ 52 | -------------------------------------------------------------------------------- /runtime/stdlib/js_nativeint.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_null.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function test(x) { 5 | return x === null; 6 | } 7 | 8 | function getExn(f) { 9 | if (f !== null) { 10 | return f; 11 | } else { 12 | throw new Error("Js.Null.getExn"); 13 | } 14 | } 15 | 16 | function bind(x, f) { 17 | if (x !== null) { 18 | return f(x); 19 | } else { 20 | return null; 21 | } 22 | } 23 | 24 | function iter(x, f) { 25 | if (x !== null) { 26 | return f(x); 27 | } else { 28 | return /* () */0; 29 | } 30 | } 31 | 32 | function fromOption(x) { 33 | if (x) { 34 | return x[0]; 35 | } else { 36 | return null; 37 | } 38 | } 39 | 40 | var from_opt = fromOption; 41 | 42 | export { 43 | test , 44 | getExn , 45 | bind , 46 | iter , 47 | fromOption , 48 | from_opt , 49 | 50 | } 51 | /* No side effect */ 52 | -------------------------------------------------------------------------------- /runtime/stdlib/js_null_undefined.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function bind(x, f) { 5 | if (x == null) { 6 | return x; 7 | } else { 8 | return f(x); 9 | } 10 | } 11 | 12 | function iter(x, f) { 13 | if (x == null) { 14 | return /* () */0; 15 | } else { 16 | return f(x); 17 | } 18 | } 19 | 20 | function fromOption(x) { 21 | if (x) { 22 | return x[0]; 23 | } else { 24 | return undefined; 25 | } 26 | } 27 | 28 | var from_opt = fromOption; 29 | 30 | export { 31 | bind , 32 | iter , 33 | fromOption , 34 | from_opt , 35 | 36 | } 37 | /* No side effect */ 38 | -------------------------------------------------------------------------------- /runtime/stdlib/js_obj.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_option.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function some(x) { 5 | return /* Some */[x]; 6 | } 7 | 8 | function isSome(param) { 9 | if (param) { 10 | return true; 11 | } else { 12 | return false; 13 | } 14 | } 15 | 16 | function isSomeValue(eq, v, x) { 17 | if (x) { 18 | return eq(v, x[0]); 19 | } else { 20 | return false; 21 | } 22 | } 23 | 24 | function isNone(param) { 25 | if (param) { 26 | return false; 27 | } else { 28 | return true; 29 | } 30 | } 31 | 32 | function getExn(x) { 33 | if (x) { 34 | return x[0]; 35 | } else { 36 | throw new Error("getExn"); 37 | } 38 | } 39 | 40 | function equal(eq, a, b) { 41 | if (a) { 42 | if (b) { 43 | return eq(a[0], b[0]); 44 | } else { 45 | return false; 46 | } 47 | } else { 48 | return b === /* None */0; 49 | } 50 | } 51 | 52 | function andThen(f, x) { 53 | if (x) { 54 | return f(x[0]); 55 | } else { 56 | return /* None */0; 57 | } 58 | } 59 | 60 | function map(f, x) { 61 | if (x) { 62 | return /* Some */[f(x[0])]; 63 | } else { 64 | return /* None */0; 65 | } 66 | } 67 | 68 | function getWithDefault(a, x) { 69 | if (x) { 70 | return x[0]; 71 | } else { 72 | return a; 73 | } 74 | } 75 | 76 | function filter(f, x) { 77 | if (x) { 78 | var x$1 = x[0]; 79 | if (f(x$1)) { 80 | return /* Some */[x$1]; 81 | } else { 82 | return /* None */0; 83 | } 84 | } else { 85 | return /* None */0; 86 | } 87 | } 88 | 89 | function firstSome(a, b) { 90 | if (a) { 91 | return a; 92 | } else if (b) { 93 | return b; 94 | } else { 95 | return /* None */0; 96 | } 97 | } 98 | 99 | var $$default = getWithDefault; 100 | 101 | export { 102 | some , 103 | isSome , 104 | isSomeValue , 105 | isNone , 106 | getExn , 107 | equal , 108 | andThen , 109 | map , 110 | getWithDefault , 111 | $$default , 112 | $$default as default, 113 | filter , 114 | firstSome , 115 | 116 | } 117 | /* No side effect */ 118 | -------------------------------------------------------------------------------- /runtime/stdlib/js_primitive.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function is_nil_undef(x) { 5 | if (x === null) { 6 | return true; 7 | } else { 8 | return x === undefined; 9 | } 10 | } 11 | 12 | function null_undefined_to_opt(x) { 13 | if (x === null || x === undefined) { 14 | return /* None */0; 15 | } else { 16 | return /* Some */[x]; 17 | } 18 | } 19 | 20 | function undefined_to_opt(x) { 21 | if (x === undefined) { 22 | return /* None */0; 23 | } else { 24 | return /* Some */[x]; 25 | } 26 | } 27 | 28 | function null_to_opt(x) { 29 | if (x === null) { 30 | return /* None */0; 31 | } else { 32 | return /* Some */[x]; 33 | } 34 | } 35 | 36 | function option_get(x) { 37 | if (x) { 38 | return x[0]; 39 | } else { 40 | return undefined; 41 | } 42 | } 43 | 44 | function option_get_unwrap(x) { 45 | if (x) { 46 | return x[0][1]; 47 | } else { 48 | return undefined; 49 | } 50 | } 51 | 52 | export { 53 | is_nil_undef , 54 | null_undefined_to_opt , 55 | undefined_to_opt , 56 | null_to_opt , 57 | option_get , 58 | option_get_unwrap , 59 | 60 | } 61 | /* No side effect */ 62 | -------------------------------------------------------------------------------- /runtime/stdlib/js_promise.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_result.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_string.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_typed_array.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var ArrayBuffer = /* module */[]; 5 | 6 | function TypedArray() { 7 | return /* module */[]; 8 | } 9 | 10 | var Int8Array = /* module */[]; 11 | 12 | var Uint8Array = /* module */[]; 13 | 14 | var Uint8ClampedArray = /* module */[]; 15 | 16 | var Int16Array = /* module */[]; 17 | 18 | var Uint16Array = /* module */[]; 19 | 20 | var Int32Array = /* module */[]; 21 | 22 | var Uint32Array = /* module */[]; 23 | 24 | var Float32Array = /* module */[]; 25 | 26 | var Float64Array = /* module */[]; 27 | 28 | var DataView = /* module */[]; 29 | 30 | var Int32_array = 0; 31 | 32 | var Float32_array = 0; 33 | 34 | var Float64_array = 0; 35 | 36 | export { 37 | ArrayBuffer , 38 | TypedArray , 39 | Int8Array , 40 | Uint8Array , 41 | Uint8ClampedArray , 42 | Int16Array , 43 | Uint16Array , 44 | Int32Array , 45 | Int32_array , 46 | Uint32Array , 47 | Float32Array , 48 | Float32_array , 49 | Float64Array , 50 | Float64_array , 51 | DataView , 52 | 53 | } 54 | /* No side effect */ 55 | -------------------------------------------------------------------------------- /runtime/stdlib/js_types.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Block from "stdlib/block.js"; 4 | 5 | function reify_type(x) { 6 | if (typeof x === "undefined") { 7 | return /* tuple */[ 8 | /* Undefined */0, 9 | x 10 | ]; 11 | } else if (x === null) { 12 | return /* tuple */[ 13 | /* Null */1, 14 | x 15 | ]; 16 | } else if (typeof x === "number") { 17 | return /* tuple */[ 18 | /* Number */3, 19 | x 20 | ]; 21 | } else if (typeof x === "string") { 22 | return /* tuple */[ 23 | /* String */4, 24 | x 25 | ]; 26 | } else if (typeof x === "boolean") { 27 | return /* tuple */[ 28 | /* Boolean */2, 29 | x 30 | ]; 31 | } else if (typeof x === "function") { 32 | return /* tuple */[ 33 | /* Function */5, 34 | x 35 | ]; 36 | } else if (typeof x === "object") { 37 | return /* tuple */[ 38 | /* Object */6, 39 | x 40 | ]; 41 | } else { 42 | return /* tuple */[ 43 | /* Symbol */7, 44 | x 45 | ]; 46 | } 47 | } 48 | 49 | function classify(x) { 50 | var ty = typeof x; 51 | if (ty === "undefined") { 52 | return /* JSUndefined */3; 53 | } else if (x === null) { 54 | return /* JSNull */2; 55 | } else if (ty === "number") { 56 | return /* JSNumber */Block.__(0, [x]); 57 | } else if (ty === "string") { 58 | return /* JSString */Block.__(1, [x]); 59 | } else if (ty === "boolean") { 60 | if (x === true) { 61 | return /* JSTrue */1; 62 | } else { 63 | return /* JSFalse */0; 64 | } 65 | } else if (ty === "function") { 66 | return /* JSFunction */Block.__(2, [x]); 67 | } else if (ty === "object") { 68 | return /* JSObject */Block.__(3, [x]); 69 | } else { 70 | return /* JSSymbol */Block.__(4, [x]); 71 | } 72 | } 73 | 74 | function test(x, v) { 75 | switch (v) { 76 | case 0 : 77 | return typeof x === "undefined"; 78 | case 1 : 79 | return x === null; 80 | case 2 : 81 | return typeof x === "boolean"; 82 | case 3 : 83 | return typeof x === "number"; 84 | case 4 : 85 | return typeof x === "string"; 86 | case 5 : 87 | return typeof x === "function"; 88 | case 6 : 89 | return typeof x === "object"; 90 | case 7 : 91 | return typeof x === "symbol"; 92 | 93 | } 94 | } 95 | 96 | export { 97 | reify_type , 98 | test , 99 | classify , 100 | 101 | } 102 | /* No side effect */ 103 | -------------------------------------------------------------------------------- /runtime/stdlib/js_undefined.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function test(x) { 5 | return x === undefined; 6 | } 7 | 8 | function testAny(x) { 9 | return x === undefined; 10 | } 11 | 12 | function getExn(f) { 13 | if (f !== undefined) { 14 | return f; 15 | } else { 16 | throw new Error("Js.Undefined.getExn"); 17 | } 18 | } 19 | 20 | function bind(x, f) { 21 | if (x !== undefined) { 22 | return f(x); 23 | } else { 24 | return undefined; 25 | } 26 | } 27 | 28 | function iter(x, f) { 29 | if (x !== undefined) { 30 | return f(x); 31 | } else { 32 | return /* () */0; 33 | } 34 | } 35 | 36 | function fromOption(x) { 37 | if (x) { 38 | return x[0]; 39 | } else { 40 | return undefined; 41 | } 42 | } 43 | 44 | var from_opt = fromOption; 45 | 46 | export { 47 | test , 48 | testAny , 49 | getExn , 50 | bind , 51 | iter , 52 | fromOption , 53 | from_opt , 54 | 55 | } 56 | /* No side effect */ 57 | -------------------------------------------------------------------------------- /runtime/stdlib/js_unsafe.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/js_vector.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function filterInPlace(p, a) { 5 | var i = 0; 6 | var j = 0; 7 | while(i < a.length) { 8 | var v = a[i]; 9 | if (p(v)) { 10 | a[j] = v; 11 | j = j + 1 | 0; 12 | } 13 | i = i + 1 | 0; 14 | }; 15 | a.splice(j); 16 | return /* () */0; 17 | } 18 | 19 | function empty(a) { 20 | a.splice(0); 21 | return /* () */0; 22 | } 23 | 24 | function pushBack(x, xs) { 25 | xs.push(x); 26 | return /* () */0; 27 | } 28 | 29 | function memByRef(x, xs) { 30 | return xs.indexOf(x) >= 0; 31 | } 32 | 33 | function iter(f, xs) { 34 | for(var i = 0 ,i_finish = xs.length - 1 | 0; i <= i_finish; ++i){ 35 | f(xs[i]); 36 | } 37 | return /* () */0; 38 | } 39 | 40 | function iteri(f, a) { 41 | for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ 42 | f(i, a[i]); 43 | } 44 | return /* () */0; 45 | } 46 | 47 | function toList(a) { 48 | var _i = a.length - 1 | 0; 49 | var _res = /* [] */0; 50 | while(true) { 51 | var res = _res; 52 | var i = _i; 53 | if (i < 0) { 54 | return res; 55 | } else { 56 | _res = /* :: */[ 57 | a[i], 58 | res 59 | ]; 60 | _i = i - 1 | 0; 61 | continue ; 62 | } 63 | }; 64 | } 65 | 66 | function init(n, f) { 67 | var v = new Array(n); 68 | for(var i = 0 ,i_finish = n - 1 | 0; i <= i_finish; ++i){ 69 | v[i] = f(i); 70 | } 71 | return v; 72 | } 73 | 74 | function copy(x) { 75 | var len = x.length; 76 | var b = new Array(len); 77 | for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ 78 | b[i] = x[i]; 79 | } 80 | return b; 81 | } 82 | 83 | function map(f, a) { 84 | var l = a.length; 85 | var r = new Array(l); 86 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 87 | r[i] = f(a[i]); 88 | } 89 | return r; 90 | } 91 | 92 | function foldLeft(f, x, a) { 93 | var r = x; 94 | for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ 95 | r = f(r, a[i]); 96 | } 97 | return r; 98 | } 99 | 100 | function foldRight(f, a, x) { 101 | var r = x; 102 | for(var i = a.length - 1 | 0; i >= 0; --i){ 103 | r = f(a[i], r); 104 | } 105 | return r; 106 | } 107 | 108 | function mapi(f, a) { 109 | var l = a.length; 110 | if (l === 0) { 111 | return /* array */[]; 112 | } else { 113 | var r = new Array(l); 114 | for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ 115 | r[i] = f(i, a[i]); 116 | } 117 | return r; 118 | } 119 | } 120 | 121 | function append(x, a) { 122 | return a.concat(/* array */[x]); 123 | } 124 | 125 | export { 126 | filterInPlace , 127 | empty , 128 | pushBack , 129 | copy , 130 | memByRef , 131 | iter , 132 | iteri , 133 | toList , 134 | map , 135 | mapi , 136 | foldLeft , 137 | foldRight , 138 | init , 139 | append , 140 | 141 | } 142 | /* No side effect */ 143 | -------------------------------------------------------------------------------- /runtime/stdlib/lazy.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Obj from "stdlib/obj.js"; 4 | import * as Block from "stdlib/block.js"; 5 | import * as Caml_obj from "stdlib/caml_obj.js"; 6 | import * as CamlinternalLazy from "stdlib/camlinternalLazy.js"; 7 | 8 | function from_fun(f) { 9 | var x = Block.__(Obj.lazy_tag, [0]); 10 | x[0] = f; 11 | return x; 12 | } 13 | 14 | function from_val(v) { 15 | var t = v.tag | 0; 16 | if (t === Obj.forward_tag || t === Obj.lazy_tag || t === Obj.double_tag) { 17 | return Caml_obj.caml_lazy_make_forward(v); 18 | } else { 19 | return v; 20 | } 21 | } 22 | 23 | function is_val(l) { 24 | return (l.tag | 0) !== Obj.lazy_tag; 25 | } 26 | 27 | var Undefined = CamlinternalLazy.Undefined; 28 | 29 | var force_val = CamlinternalLazy.force_val; 30 | 31 | var lazy_from_fun = from_fun; 32 | 33 | var lazy_from_val = from_val; 34 | 35 | var lazy_is_val = is_val; 36 | 37 | export { 38 | Undefined , 39 | force_val , 40 | from_fun , 41 | from_val , 42 | is_val , 43 | lazy_from_fun , 44 | lazy_from_val , 45 | lazy_is_val , 46 | 47 | } 48 | /* No side effect */ 49 | -------------------------------------------------------------------------------- /runtime/stdlib/listLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as List from "stdlib/list.js"; 4 | 5 | var length = List.length; 6 | 7 | var hd = List.hd; 8 | 9 | var tl = List.tl; 10 | 11 | var nth = List.nth; 12 | 13 | var rev = List.rev; 14 | 15 | var append = List.append; 16 | 17 | var rev_append = List.rev_append; 18 | 19 | var concat = List.concat; 20 | 21 | var flatten = List.flatten; 22 | 23 | var iter = List.iter; 24 | 25 | var iteri = List.iteri; 26 | 27 | var map = List.map; 28 | 29 | var mapi = List.mapi; 30 | 31 | var rev_map = List.rev_map; 32 | 33 | var fold_left = List.fold_left; 34 | 35 | var fold_right = List.fold_right; 36 | 37 | var iter2 = List.iter2; 38 | 39 | var map2 = List.map2; 40 | 41 | var rev_map2 = List.rev_map2; 42 | 43 | var fold_left2 = List.fold_left2; 44 | 45 | var fold_right2 = List.fold_right2; 46 | 47 | var for_all = List.for_all; 48 | 49 | var exists = List.exists; 50 | 51 | var for_all2 = List.for_all2; 52 | 53 | var exists2 = List.exists2; 54 | 55 | var mem = List.mem; 56 | 57 | var memq = List.memq; 58 | 59 | var find = List.find; 60 | 61 | var filter = List.filter; 62 | 63 | var find_all = List.find_all; 64 | 65 | var partition = List.partition; 66 | 67 | var assoc = List.assoc; 68 | 69 | var assq = List.assq; 70 | 71 | var mem_assoc = List.mem_assoc; 72 | 73 | var mem_assq = List.mem_assq; 74 | 75 | var remove_assoc = List.remove_assoc; 76 | 77 | var remove_assq = List.remove_assq; 78 | 79 | var split = List.split; 80 | 81 | var combine = List.combine; 82 | 83 | var sort = List.sort; 84 | 85 | var stable_sort = List.stable_sort; 86 | 87 | var fast_sort = List.fast_sort; 88 | 89 | var merge = List.merge; 90 | 91 | export { 92 | length , 93 | hd , 94 | tl , 95 | nth , 96 | rev , 97 | append , 98 | rev_append , 99 | concat , 100 | flatten , 101 | iter , 102 | iteri , 103 | map , 104 | mapi , 105 | rev_map , 106 | fold_left , 107 | fold_right , 108 | iter2 , 109 | map2 , 110 | rev_map2 , 111 | fold_left2 , 112 | fold_right2 , 113 | for_all , 114 | exists , 115 | for_all2 , 116 | exists2 , 117 | mem , 118 | memq , 119 | find , 120 | filter , 121 | find_all , 122 | partition , 123 | assoc , 124 | assq , 125 | mem_assoc , 126 | mem_assq , 127 | remove_assoc , 128 | remove_assq , 129 | split , 130 | combine , 131 | sort , 132 | stable_sort , 133 | fast_sort , 134 | merge , 135 | 136 | } 137 | /* No side effect */ 138 | -------------------------------------------------------------------------------- /runtime/stdlib/marshal.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_string from "stdlib/caml_string.js"; 4 | import * as Caml_missing_polyfill from "stdlib/caml_missing_polyfill.js"; 5 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 6 | 7 | function to_buffer(buff, ofs, len, _, _$1) { 8 | if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) { 9 | throw [ 10 | Caml_builtin_exceptions.invalid_argument, 11 | "Marshal.to_buffer: substring out of bounds" 12 | ]; 13 | } else { 14 | return Caml_missing_polyfill.not_implemented("caml_output_value_to_buffer"); 15 | } 16 | } 17 | 18 | function data_size(buff, ofs) { 19 | if (ofs < 0 || ofs > (buff.length - 20 | 0)) { 20 | throw [ 21 | Caml_builtin_exceptions.invalid_argument, 22 | "Marshal.data_size" 23 | ]; 24 | } else { 25 | return Caml_missing_polyfill.not_implemented("caml_marshal_data_size"); 26 | } 27 | } 28 | 29 | function total_size(buff, ofs) { 30 | return 20 + data_size(buff, ofs) | 0; 31 | } 32 | 33 | function from_bytes(buff, ofs) { 34 | if (ofs < 0 || ofs > (buff.length - 20 | 0)) { 35 | throw [ 36 | Caml_builtin_exceptions.invalid_argument, 37 | "Marshal.from_bytes" 38 | ]; 39 | } else { 40 | var len = Caml_missing_polyfill.not_implemented("caml_marshal_data_size"); 41 | if (ofs > (buff.length - (20 + len | 0) | 0)) { 42 | throw [ 43 | Caml_builtin_exceptions.invalid_argument, 44 | "Marshal.from_bytes" 45 | ]; 46 | } else { 47 | return Caml_missing_polyfill.not_implemented("caml_input_value_from_string"); 48 | } 49 | } 50 | } 51 | 52 | function from_string(buff, ofs) { 53 | return from_bytes(Caml_string.bytes_of_string(buff), ofs); 54 | } 55 | 56 | function to_channel(_, _$1, _$2) { 57 | return Caml_missing_polyfill.not_implemented("caml_output_value"); 58 | } 59 | 60 | function from_channel() { 61 | return Caml_missing_polyfill.not_implemented("caml_input_value"); 62 | } 63 | 64 | var header_size = 20; 65 | 66 | export { 67 | to_channel , 68 | to_buffer , 69 | from_channel , 70 | from_bytes , 71 | from_string , 72 | header_size , 73 | data_size , 74 | total_size , 75 | 76 | } 77 | /* No side effect */ 78 | -------------------------------------------------------------------------------- /runtime/stdlib/moreLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as $$Map from "stdlib/map.js"; 4 | import * as $$Set from "stdlib/set.js"; 5 | import * as Hashtbl from "stdlib/hashtbl.js"; 6 | 7 | var Hashtbl$1 = /* Hashtbl */[ 8 | Hashtbl.create, 9 | Hashtbl.clear, 10 | Hashtbl.reset, 11 | Hashtbl.copy, 12 | Hashtbl.add, 13 | Hashtbl.find, 14 | Hashtbl.find_all, 15 | Hashtbl.mem, 16 | Hashtbl.remove, 17 | Hashtbl.replace, 18 | Hashtbl.iter, 19 | Hashtbl.fold, 20 | Hashtbl.length, 21 | Hashtbl.randomize, 22 | Hashtbl.stats, 23 | Hashtbl.Make, 24 | Hashtbl.MakeSeeded, 25 | Hashtbl.hash, 26 | Hashtbl.seeded_hash, 27 | Hashtbl.hash_param, 28 | Hashtbl.seeded_hash_param 29 | ]; 30 | 31 | var $$Map$1 = /* Map */[$$Map.Make]; 32 | 33 | var $$Set$1 = /* Set */[$$Set.Make]; 34 | 35 | export { 36 | Hashtbl$1 as Hashtbl, 37 | $$Map$1 as $$Map, 38 | $$Set$1 as $$Set, 39 | 40 | } 41 | /* No side effect */ 42 | -------------------------------------------------------------------------------- /runtime/stdlib/nativeint.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_format from "stdlib/caml_format.js"; 4 | import * as Caml_primitive from "stdlib/caml_primitive.js"; 5 | 6 | function succ(n) { 7 | return n + 1; 8 | } 9 | 10 | function pred(n) { 11 | return n - 1; 12 | } 13 | 14 | function abs(n) { 15 | if (n >= 0) { 16 | return n; 17 | } else { 18 | return -n; 19 | } 20 | } 21 | 22 | function lognot(n) { 23 | return n ^ -1; 24 | } 25 | 26 | function to_string(n) { 27 | return Caml_format.caml_nativeint_format("%d", n); 28 | } 29 | 30 | var compare = Caml_primitive.caml_nativeint_compare; 31 | 32 | var zero = 0; 33 | 34 | var one = 1; 35 | 36 | var minus_one = -1; 37 | 38 | var size = 54; 39 | 40 | var max_int = 9007199254740991; 41 | 42 | var min_int = -9007199254740991; 43 | 44 | export { 45 | zero , 46 | one , 47 | minus_one , 48 | succ , 49 | pred , 50 | abs , 51 | size , 52 | max_int , 53 | min_int , 54 | lognot , 55 | to_string , 56 | compare , 57 | 58 | } 59 | /* No side effect */ 60 | -------------------------------------------------------------------------------- /runtime/stdlib/node.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | function test(x) { 5 | if (typeof x === "string") { 6 | return /* tuple */[ 7 | /* String */0, 8 | x 9 | ]; 10 | } else { 11 | return /* tuple */[ 12 | /* Buffer */1, 13 | x 14 | ]; 15 | } 16 | } 17 | 18 | var Path = 0; 19 | 20 | var Fs = 0; 21 | 22 | var Process = 0; 23 | 24 | var Module = 0; 25 | 26 | var $$Buffer = 0; 27 | 28 | var Child_process = 0; 29 | 30 | export { 31 | Path , 32 | Fs , 33 | Process , 34 | Module , 35 | $$Buffer , 36 | Child_process , 37 | test , 38 | 39 | } 40 | /* No side effect */ 41 | -------------------------------------------------------------------------------- /runtime/stdlib/node_buffer.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/node_child_process.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/node_fs.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var Watch = /* module */[]; 5 | 6 | export { 7 | Watch , 8 | 9 | } 10 | /* No side effect */ 11 | -------------------------------------------------------------------------------- /runtime/stdlib/node_module.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/node_path.js: -------------------------------------------------------------------------------- 1 | /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ 2 | -------------------------------------------------------------------------------- /runtime/stdlib/node_process.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Js_dict from "stdlib/js_dict.js"; 4 | import * as Process from "process"; 5 | 6 | function putEnvVar(key, $$var) { 7 | Process.env[key] = $$var; 8 | return /* () */0; 9 | } 10 | 11 | function deleteEnvVar(s) { 12 | return Js_dict.unsafeDeleteKey(Process.env, s); 13 | } 14 | 15 | export { 16 | putEnvVar , 17 | deleteEnvVar , 18 | 19 | } 20 | /* Js_dict Not a pure module */ 21 | -------------------------------------------------------------------------------- /runtime/stdlib/obj.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Marshal from "stdlib/marshal.js"; 4 | import * as Caml_array from "stdlib/caml_array.js"; 5 | import * as Caml_missing_polyfill from "stdlib/caml_missing_polyfill.js"; 6 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 7 | 8 | var double_field = Caml_array.caml_array_get; 9 | 10 | var set_double_field = Caml_array.caml_array_set; 11 | 12 | function marshal() { 13 | return Caml_missing_polyfill.not_implemented("caml_output_value_to_string"); 14 | } 15 | 16 | function unmarshal(str, pos) { 17 | return /* tuple */[ 18 | Marshal.from_bytes(str, pos), 19 | pos + Marshal.total_size(str, pos) | 0 20 | ]; 21 | } 22 | 23 | function extension_slot(x) { 24 | var slot = x.length !== undefined && (x.tag | 0) !== 248 && x.length >= 1 ? x[0] : x; 25 | var name; 26 | if (slot.length !== undefined && slot.tag === 248) { 27 | name = slot[0]; 28 | } else { 29 | throw Caml_builtin_exceptions.not_found; 30 | } 31 | if (name.tag === 252) { 32 | return slot; 33 | } else { 34 | throw Caml_builtin_exceptions.not_found; 35 | } 36 | } 37 | 38 | function extension_name(x) { 39 | try { 40 | var slot = extension_slot(x); 41 | return slot[0]; 42 | } 43 | catch (exn){ 44 | if (exn === Caml_builtin_exceptions.not_found) { 45 | throw [ 46 | Caml_builtin_exceptions.invalid_argument, 47 | "Obj.extension_name" 48 | ]; 49 | } else { 50 | throw exn; 51 | } 52 | } 53 | } 54 | 55 | function extension_id(x) { 56 | try { 57 | var slot = extension_slot(x); 58 | return slot[1]; 59 | } 60 | catch (exn){ 61 | if (exn === Caml_builtin_exceptions.not_found) { 62 | throw [ 63 | Caml_builtin_exceptions.invalid_argument, 64 | "Obj.extension_id" 65 | ]; 66 | } else { 67 | throw exn; 68 | } 69 | } 70 | } 71 | 72 | function extension_slot$1(x) { 73 | try { 74 | return extension_slot(x); 75 | } 76 | catch (exn){ 77 | if (exn === Caml_builtin_exceptions.not_found) { 78 | throw [ 79 | Caml_builtin_exceptions.invalid_argument, 80 | "Obj.extension_slot" 81 | ]; 82 | } else { 83 | throw exn; 84 | } 85 | } 86 | } 87 | 88 | var first_non_constant_constructor_tag = 0; 89 | 90 | var last_non_constant_constructor_tag = 245; 91 | 92 | var lazy_tag = 246; 93 | 94 | var closure_tag = 247; 95 | 96 | var object_tag = 248; 97 | 98 | var infix_tag = 249; 99 | 100 | var forward_tag = 250; 101 | 102 | var no_scan_tag = 251; 103 | 104 | var abstract_tag = 251; 105 | 106 | var string_tag = 252; 107 | 108 | var double_tag = 253; 109 | 110 | var double_array_tag = 254; 111 | 112 | var custom_tag = 255; 113 | 114 | var final_tag = 255; 115 | 116 | var int_tag = 1000; 117 | 118 | var out_of_heap_tag = 1001; 119 | 120 | var unaligned_tag = 1002; 121 | 122 | export { 123 | double_field , 124 | set_double_field , 125 | first_non_constant_constructor_tag , 126 | last_non_constant_constructor_tag , 127 | lazy_tag , 128 | closure_tag , 129 | object_tag , 130 | infix_tag , 131 | forward_tag , 132 | no_scan_tag , 133 | abstract_tag , 134 | string_tag , 135 | double_tag , 136 | double_array_tag , 137 | custom_tag , 138 | final_tag , 139 | int_tag , 140 | out_of_heap_tag , 141 | unaligned_tag , 142 | extension_name , 143 | extension_id , 144 | extension_slot$1 as extension_slot, 145 | marshal , 146 | unmarshal , 147 | 148 | } 149 | /* No side effect */ 150 | -------------------------------------------------------------------------------- /runtime/stdlib/oo.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as CamlinternalOO from "stdlib/camlinternalOO.js"; 4 | 5 | var copy = CamlinternalOO.copy; 6 | 7 | var new_method = CamlinternalOO.public_method_label; 8 | 9 | var public_method_label = CamlinternalOO.public_method_label; 10 | 11 | export { 12 | copy , 13 | new_method , 14 | public_method_label , 15 | 16 | } 17 | /* No side effect */ 18 | -------------------------------------------------------------------------------- /runtime/stdlib/printf.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as $$Buffer from "stdlib/buffer.js"; 5 | import * as Pervasives from "stdlib/pervasives.js"; 6 | import * as CamlinternalFormat from "stdlib/camlinternalFormat.js"; 7 | 8 | function kfprintf(k, o, param) { 9 | return CamlinternalFormat.make_printf((function (o, acc) { 10 | CamlinternalFormat.output_acc(o, acc); 11 | return Curry._1(k, o); 12 | }), o, /* End_of_acc */0, param[0]); 13 | } 14 | 15 | function kbprintf(k, b, param) { 16 | return CamlinternalFormat.make_printf((function (b, acc) { 17 | CamlinternalFormat.bufput_acc(b, acc); 18 | return Curry._1(k, b); 19 | }), b, /* End_of_acc */0, param[0]); 20 | } 21 | 22 | function ikfprintf(k, oc, param) { 23 | return CamlinternalFormat.make_printf((function (oc, _) { 24 | return Curry._1(k, oc); 25 | }), oc, /* End_of_acc */0, param[0]); 26 | } 27 | 28 | function fprintf(oc, fmt) { 29 | return kfprintf((function () { 30 | return /* () */0; 31 | }), oc, fmt); 32 | } 33 | 34 | function bprintf(b, fmt) { 35 | return kbprintf((function () { 36 | return /* () */0; 37 | }), b, fmt); 38 | } 39 | 40 | function ifprintf(oc, fmt) { 41 | return ikfprintf((function () { 42 | return /* () */0; 43 | }), oc, fmt); 44 | } 45 | 46 | function printf(fmt) { 47 | return fprintf(Pervasives.stdout, fmt); 48 | } 49 | 50 | function eprintf(fmt) { 51 | return fprintf(Pervasives.stderr, fmt); 52 | } 53 | 54 | function ksprintf(k, param) { 55 | var k$prime = function (_, acc) { 56 | var buf = $$Buffer.create(64); 57 | CamlinternalFormat.strput_acc(buf, acc); 58 | return Curry._1(k, $$Buffer.contents(buf)); 59 | }; 60 | return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[0]); 61 | } 62 | 63 | function sprintf(fmt) { 64 | return ksprintf((function (s) { 65 | return s; 66 | }), fmt); 67 | } 68 | 69 | var kprintf = ksprintf; 70 | 71 | export { 72 | fprintf , 73 | printf , 74 | eprintf , 75 | sprintf , 76 | bprintf , 77 | ifprintf , 78 | kfprintf , 79 | ikfprintf , 80 | ksprintf , 81 | kbprintf , 82 | kprintf , 83 | 84 | } 85 | /* No side effect */ 86 | -------------------------------------------------------------------------------- /runtime/stdlib/queue.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as Caml_obj from "stdlib/caml_obj.js"; 5 | import * as Caml_exceptions from "stdlib/caml_exceptions.js"; 6 | 7 | var Empty = Caml_exceptions.create("Queue.Empty"); 8 | 9 | function create() { 10 | return /* record */[ 11 | /* length */0, 12 | /* tail : None */0 13 | ]; 14 | } 15 | 16 | function clear(q) { 17 | q[/* length */0] = 0; 18 | q[/* tail */1] = /* None */0; 19 | return /* () */0; 20 | } 21 | 22 | function add(x, q) { 23 | if (q[/* length */0] === 0) { 24 | var cell = []; 25 | cell[0] = x; 26 | cell[1] = cell; 27 | q[/* length */0] = 1; 28 | q[/* tail */1] = cell; 29 | return /* () */0; 30 | } else { 31 | var tail = q[/* tail */1]; 32 | var head = tail[/* next */1]; 33 | var cell$1 = /* record */[ 34 | /* content */x, 35 | /* next */head 36 | ]; 37 | q[/* length */0] = q[/* length */0] + 1 | 0; 38 | tail[/* next */1] = cell$1; 39 | q[/* tail */1] = cell$1; 40 | return /* () */0; 41 | } 42 | } 43 | 44 | function peek(q) { 45 | if (q[/* length */0] === 0) { 46 | throw Empty; 47 | } else { 48 | return q[/* tail */1][/* next */1][/* content */0]; 49 | } 50 | } 51 | 52 | function take(q) { 53 | if (q[/* length */0] === 0) { 54 | throw Empty; 55 | } 56 | q[/* length */0] = q[/* length */0] - 1 | 0; 57 | var tail = q[/* tail */1]; 58 | var head = tail[/* next */1]; 59 | if (head === tail) { 60 | q[/* tail */1] = /* None */0; 61 | } else { 62 | tail[/* next */1] = head[/* next */1]; 63 | } 64 | return head[/* content */0]; 65 | } 66 | 67 | function copy(q) { 68 | if (q[/* length */0] === 0) { 69 | return /* record */[ 70 | /* length */0, 71 | /* tail : None */0 72 | ]; 73 | } else { 74 | var tail = q[/* tail */1]; 75 | var tail$prime = []; 76 | Caml_obj.caml_update_dummy(tail$prime, /* record */[ 77 | /* content */tail[/* content */0], 78 | /* next */tail$prime 79 | ]); 80 | var copy$1 = function (_prev, _cell) { 81 | while(true) { 82 | var cell = _cell; 83 | var prev = _prev; 84 | if (cell !== tail) { 85 | var res = /* record */[ 86 | /* content */cell[/* content */0], 87 | /* next */tail$prime 88 | ]; 89 | prev[/* next */1] = res; 90 | _cell = cell[/* next */1]; 91 | _prev = res; 92 | continue ; 93 | } else { 94 | return 0; 95 | } 96 | }; 97 | }; 98 | copy$1(tail$prime, tail[/* next */1]); 99 | return /* record */[ 100 | /* length */q[/* length */0], 101 | /* tail */tail$prime 102 | ]; 103 | } 104 | } 105 | 106 | function is_empty(q) { 107 | return q[/* length */0] === 0; 108 | } 109 | 110 | function length(q) { 111 | return q[/* length */0]; 112 | } 113 | 114 | function iter(f, q) { 115 | if (q[/* length */0] > 0) { 116 | var tail = q[/* tail */1]; 117 | var _cell = tail[/* next */1]; 118 | while(true) { 119 | var cell = _cell; 120 | Curry._1(f, cell[/* content */0]); 121 | if (cell !== tail) { 122 | _cell = cell[/* next */1]; 123 | continue ; 124 | } else { 125 | return 0; 126 | } 127 | }; 128 | } else { 129 | return 0; 130 | } 131 | } 132 | 133 | function fold(f, accu, q) { 134 | if (q[/* length */0] === 0) { 135 | return accu; 136 | } else { 137 | var tail = q[/* tail */1]; 138 | var _accu = accu; 139 | var _cell = tail[/* next */1]; 140 | while(true) { 141 | var cell = _cell; 142 | var accu$1 = _accu; 143 | var accu$2 = Curry._2(f, accu$1, cell[/* content */0]); 144 | if (cell === tail) { 145 | return accu$2; 146 | } else { 147 | _cell = cell[/* next */1]; 148 | _accu = accu$2; 149 | continue ; 150 | } 151 | }; 152 | } 153 | } 154 | 155 | function transfer(q1, q2) { 156 | var length1 = q1[/* length */0]; 157 | if (length1 > 0) { 158 | var tail1 = q1[/* tail */1]; 159 | clear(q1); 160 | if (q2[/* length */0] > 0) { 161 | var tail2 = q2[/* tail */1]; 162 | var head1 = tail1[/* next */1]; 163 | var head2 = tail2[/* next */1]; 164 | tail1[/* next */1] = head2; 165 | tail2[/* next */1] = head1; 166 | } 167 | q2[/* length */0] = q2[/* length */0] + length1 | 0; 168 | q2[/* tail */1] = tail1; 169 | return /* () */0; 170 | } else { 171 | return 0; 172 | } 173 | } 174 | 175 | var push = add; 176 | 177 | var pop = take; 178 | 179 | var top = peek; 180 | 181 | export { 182 | Empty , 183 | create , 184 | add , 185 | push , 186 | take , 187 | pop , 188 | peek , 189 | top , 190 | clear , 191 | copy , 192 | is_empty , 193 | length , 194 | iter , 195 | fold , 196 | transfer , 197 | 198 | } 199 | /* No side effect */ 200 | -------------------------------------------------------------------------------- /runtime/stdlib/sort.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Curry from "stdlib/curry.js"; 4 | import * as Caml_builtin_exceptions from "stdlib/caml_builtin_exceptions.js"; 5 | 6 | function merge(order, l1, l2) { 7 | if (l1) { 8 | if (l2) { 9 | var h2 = l2[0]; 10 | var h1 = l1[0]; 11 | if (Curry._2(order, h1, h2)) { 12 | return /* :: */[ 13 | h1, 14 | merge(order, l1[1], l2) 15 | ]; 16 | } else { 17 | return /* :: */[ 18 | h2, 19 | merge(order, l1, l2[1]) 20 | ]; 21 | } 22 | } else { 23 | return l1; 24 | } 25 | } else { 26 | return l2; 27 | } 28 | } 29 | 30 | function list(order, l) { 31 | var initlist = function (param) { 32 | if (param) { 33 | var match = param[1]; 34 | var e = param[0]; 35 | if (match) { 36 | var e2 = match[0]; 37 | return /* :: */[ 38 | Curry._2(order, e, e2) ? /* :: */[ 39 | e, 40 | /* :: */[ 41 | e2, 42 | /* [] */0 43 | ] 44 | ] : /* :: */[ 45 | e2, 46 | /* :: */[ 47 | e, 48 | /* [] */0 49 | ] 50 | ], 51 | initlist(match[1]) 52 | ]; 53 | } else { 54 | return /* :: */[ 55 | /* :: */[ 56 | e, 57 | /* [] */0 58 | ], 59 | /* [] */0 60 | ]; 61 | } 62 | } else { 63 | return /* [] */0; 64 | } 65 | }; 66 | var merge2 = function (x) { 67 | if (x) { 68 | var match = x[1]; 69 | if (match) { 70 | return /* :: */[ 71 | merge(order, x[0], match[0]), 72 | merge2(match[1]) 73 | ]; 74 | } else { 75 | return x; 76 | } 77 | } else { 78 | return x; 79 | } 80 | }; 81 | var _llist = initlist(l); 82 | while(true) { 83 | var llist = _llist; 84 | if (llist) { 85 | if (llist[1]) { 86 | _llist = merge2(llist); 87 | continue ; 88 | } else { 89 | return llist[0]; 90 | } 91 | } else { 92 | return /* [] */0; 93 | } 94 | }; 95 | } 96 | 97 | function swap(arr, i, j) { 98 | var tmp = arr[i]; 99 | arr[i] = arr[j]; 100 | arr[j] = tmp; 101 | return /* () */0; 102 | } 103 | 104 | function array(cmp, arr) { 105 | var qsort = function (_lo, _hi) { 106 | while(true) { 107 | var hi = _hi; 108 | var lo = _lo; 109 | if ((hi - lo | 0) >= 6) { 110 | var mid = ((lo + hi | 0) >>> 1); 111 | if (Curry._2(cmp, arr[mid], arr[lo])) { 112 | swap(arr, mid, lo); 113 | } 114 | if (Curry._2(cmp, arr[hi], arr[mid])) { 115 | swap(arr, mid, hi); 116 | if (Curry._2(cmp, arr[mid], arr[lo])) { 117 | swap(arr, mid, lo); 118 | } 119 | 120 | } 121 | var pivot = arr[mid]; 122 | var i = lo + 1 | 0; 123 | var j = hi - 1 | 0; 124 | if (!Curry._2(cmp, pivot, arr[hi]) || !Curry._2(cmp, arr[lo], pivot)) { 125 | throw [ 126 | Caml_builtin_exceptions.invalid_argument, 127 | "Sort.array" 128 | ]; 129 | } 130 | while(i < j) { 131 | while(!Curry._2(cmp, pivot, arr[i])) { 132 | i = i + 1 | 0; 133 | }; 134 | while(!Curry._2(cmp, arr[j], pivot)) { 135 | j = j - 1 | 0; 136 | }; 137 | if (i < j) { 138 | swap(arr, i, j); 139 | } 140 | i = i + 1 | 0; 141 | j = j - 1 | 0; 142 | }; 143 | if ((j - lo | 0) <= (hi - i | 0)) { 144 | qsort(lo, j); 145 | _lo = i; 146 | continue ; 147 | } else { 148 | qsort(i, hi); 149 | _hi = j; 150 | continue ; 151 | } 152 | } else { 153 | return 0; 154 | } 155 | }; 156 | }; 157 | qsort(0, arr.length - 1 | 0); 158 | for(var i = 1 ,i_finish = arr.length - 1 | 0; i <= i_finish; ++i){ 159 | var val_i = arr[i]; 160 | if (!Curry._2(cmp, arr[i - 1 | 0], val_i)) { 161 | arr[i] = arr[i - 1 | 0]; 162 | var j = i - 1 | 0; 163 | while(j >= 1 && !Curry._2(cmp, arr[j - 1 | 0], val_i)) { 164 | arr[j] = arr[j - 1 | 0]; 165 | j = j - 1 | 0; 166 | }; 167 | arr[j] = val_i; 168 | } 169 | 170 | } 171 | return /* () */0; 172 | } 173 | 174 | export { 175 | list , 176 | array , 177 | merge , 178 | 179 | } 180 | /* No side effect */ 181 | -------------------------------------------------------------------------------- /runtime/stdlib/stack.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as List from "stdlib/list.js"; 4 | import * as Caml_exceptions from "stdlib/caml_exceptions.js"; 5 | 6 | var Empty = Caml_exceptions.create("Stack.Empty"); 7 | 8 | function create() { 9 | return /* record */[/* c : [] */0]; 10 | } 11 | 12 | function clear(s) { 13 | s[/* c */0] = /* [] */0; 14 | return /* () */0; 15 | } 16 | 17 | function copy(s) { 18 | return /* record */[/* c */s[/* c */0]]; 19 | } 20 | 21 | function push(x, s) { 22 | s[/* c */0] = /* :: */[ 23 | x, 24 | s[/* c */0] 25 | ]; 26 | return /* () */0; 27 | } 28 | 29 | function pop(s) { 30 | var match = s[/* c */0]; 31 | if (match) { 32 | s[/* c */0] = match[1]; 33 | return match[0]; 34 | } else { 35 | throw Empty; 36 | } 37 | } 38 | 39 | function top(s) { 40 | var match = s[/* c */0]; 41 | if (match) { 42 | return match[0]; 43 | } else { 44 | throw Empty; 45 | } 46 | } 47 | 48 | function is_empty(s) { 49 | return s[/* c */0] === /* [] */0; 50 | } 51 | 52 | function length(s) { 53 | return List.length(s[/* c */0]); 54 | } 55 | 56 | function iter(f, s) { 57 | return List.iter(f, s[/* c */0]); 58 | } 59 | 60 | export { 61 | Empty , 62 | create , 63 | push , 64 | pop , 65 | top , 66 | clear , 67 | copy , 68 | is_empty , 69 | length , 70 | iter , 71 | 72 | } 73 | /* No side effect */ 74 | -------------------------------------------------------------------------------- /runtime/stdlib/stdLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | var $$Array = 0; 5 | 6 | var Bytes = 0; 7 | 8 | var List = 0; 9 | 10 | var $$String = 0; 11 | 12 | export { 13 | $$Array , 14 | Bytes , 15 | List , 16 | $$String , 17 | 18 | } 19 | /* No side effect */ 20 | -------------------------------------------------------------------------------- /runtime/stdlib/std_exit.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Pervasives from "stdlib/pervasives.js"; 4 | 5 | Pervasives.do_at_exit(/* () */0); 6 | 7 | export { 8 | 9 | } 10 | /* Not a pure module */ 11 | -------------------------------------------------------------------------------- /runtime/stdlib/string.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as List from "stdlib/list.js"; 4 | import * as Bytes from "stdlib/bytes.js"; 5 | import * as Caml_int32 from "stdlib/caml_int32.js"; 6 | import * as Caml_string from "stdlib/caml_string.js"; 7 | import * as Caml_primitive from "stdlib/caml_primitive.js"; 8 | 9 | function make(n, c) { 10 | return Caml_string.bytes_to_string(Bytes.make(n, c)); 11 | } 12 | 13 | function init(n, f) { 14 | return Caml_string.bytes_to_string(Bytes.init(n, f)); 15 | } 16 | 17 | function copy(s) { 18 | return Caml_string.bytes_to_string(Bytes.copy(Caml_string.bytes_of_string(s))); 19 | } 20 | 21 | function sub(s, ofs, len) { 22 | return Caml_string.bytes_to_string(Bytes.sub(Caml_string.bytes_of_string(s), ofs, len)); 23 | } 24 | 25 | function concat(sep, l) { 26 | if (l) { 27 | var hd = l[0]; 28 | var num = [0]; 29 | var len = [0]; 30 | List.iter((function (s) { 31 | num[0] = num[0] + 1 | 0; 32 | len[0] = len[0] + s.length | 0; 33 | return /* () */0; 34 | }), l); 35 | var r = Caml_string.caml_create_string(len[0] + Caml_int32.imul(sep.length, num[0] - 1 | 0) | 0); 36 | Caml_string.caml_blit_string(hd, 0, r, 0, hd.length); 37 | var pos = [hd.length]; 38 | List.iter((function (s) { 39 | Caml_string.caml_blit_string(sep, 0, r, pos[0], sep.length); 40 | pos[0] = pos[0] + sep.length | 0; 41 | Caml_string.caml_blit_string(s, 0, r, pos[0], s.length); 42 | pos[0] = pos[0] + s.length | 0; 43 | return /* () */0; 44 | }), l[1]); 45 | return Caml_string.bytes_to_string(r); 46 | } else { 47 | return ""; 48 | } 49 | } 50 | 51 | function iter(f, s) { 52 | return Bytes.iter(f, Caml_string.bytes_of_string(s)); 53 | } 54 | 55 | function iteri(f, s) { 56 | return Bytes.iteri(f, Caml_string.bytes_of_string(s)); 57 | } 58 | 59 | function map(f, s) { 60 | return Caml_string.bytes_to_string(Bytes.map(f, Caml_string.bytes_of_string(s))); 61 | } 62 | 63 | function mapi(f, s) { 64 | return Caml_string.bytes_to_string(Bytes.mapi(f, Caml_string.bytes_of_string(s))); 65 | } 66 | 67 | function is_space(param) { 68 | var switcher = param - 9 | 0; 69 | if (switcher > 4 || switcher < 0) { 70 | return switcher === 23; 71 | } else { 72 | return switcher !== 2; 73 | } 74 | } 75 | 76 | function trim(s) { 77 | if (s === "" || !(is_space(s.charCodeAt(0)) || is_space(s.charCodeAt(s.length - 1 | 0)))) { 78 | return s; 79 | } else { 80 | return Caml_string.bytes_to_string(Bytes.trim(Caml_string.bytes_of_string(s))); 81 | } 82 | } 83 | 84 | function escaped(s) { 85 | var needs_escape = function (_i) { 86 | while(true) { 87 | var i = _i; 88 | if (i >= s.length) { 89 | return false; 90 | } else { 91 | var match = s.charCodeAt(i); 92 | if (match >= 32) { 93 | var switcher = match - 34 | 0; 94 | if (switcher > 58 || switcher < 0) { 95 | if (switcher >= 93) { 96 | return true; 97 | } else { 98 | _i = i + 1 | 0; 99 | continue ; 100 | } 101 | } else if (switcher > 57 || switcher < 1) { 102 | return true; 103 | } else { 104 | _i = i + 1 | 0; 105 | continue ; 106 | } 107 | } else { 108 | return true; 109 | } 110 | } 111 | }; 112 | }; 113 | if (needs_escape(0)) { 114 | return Caml_string.bytes_to_string(Bytes.escaped(Caml_string.bytes_of_string(s))); 115 | } else { 116 | return s; 117 | } 118 | } 119 | 120 | function index(s, c) { 121 | return Bytes.index(Caml_string.bytes_of_string(s), c); 122 | } 123 | 124 | function rindex(s, c) { 125 | return Bytes.rindex(Caml_string.bytes_of_string(s), c); 126 | } 127 | 128 | function index_from(s, i, c) { 129 | return Bytes.index_from(Caml_string.bytes_of_string(s), i, c); 130 | } 131 | 132 | function rindex_from(s, i, c) { 133 | return Bytes.rindex_from(Caml_string.bytes_of_string(s), i, c); 134 | } 135 | 136 | function contains(s, c) { 137 | return Bytes.contains(Caml_string.bytes_of_string(s), c); 138 | } 139 | 140 | function contains_from(s, i, c) { 141 | return Bytes.contains_from(Caml_string.bytes_of_string(s), i, c); 142 | } 143 | 144 | function rcontains_from(s, i, c) { 145 | return Bytes.rcontains_from(Caml_string.bytes_of_string(s), i, c); 146 | } 147 | 148 | function uppercase(s) { 149 | return Caml_string.bytes_to_string(Bytes.uppercase(Caml_string.bytes_of_string(s))); 150 | } 151 | 152 | function lowercase(s) { 153 | return Caml_string.bytes_to_string(Bytes.lowercase(Caml_string.bytes_of_string(s))); 154 | } 155 | 156 | function capitalize(s) { 157 | return Caml_string.bytes_to_string(Bytes.capitalize(Caml_string.bytes_of_string(s))); 158 | } 159 | 160 | function uncapitalize(s) { 161 | return Caml_string.bytes_to_string(Bytes.uncapitalize(Caml_string.bytes_of_string(s))); 162 | } 163 | 164 | var compare = Caml_primitive.caml_string_compare; 165 | 166 | var fill = Bytes.fill; 167 | 168 | var blit = Bytes.blit_string; 169 | 170 | export { 171 | make , 172 | init , 173 | copy , 174 | sub , 175 | fill , 176 | blit , 177 | concat , 178 | iter , 179 | iteri , 180 | map , 181 | mapi , 182 | trim , 183 | escaped , 184 | index , 185 | rindex , 186 | index_from , 187 | rindex_from , 188 | contains , 189 | contains_from , 190 | rcontains_from , 191 | uppercase , 192 | lowercase , 193 | capitalize , 194 | uncapitalize , 195 | compare , 196 | 197 | } 198 | /* No side effect */ 199 | -------------------------------------------------------------------------------- /runtime/stdlib/stringLabels.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as $$String from "stdlib/string.js"; 4 | 5 | var make = $$String.make; 6 | 7 | var init = $$String.init; 8 | 9 | var copy = $$String.copy; 10 | 11 | var sub = $$String.sub; 12 | 13 | var fill = $$String.fill; 14 | 15 | var blit = $$String.blit; 16 | 17 | var concat = $$String.concat; 18 | 19 | var iter = $$String.iter; 20 | 21 | var iteri = $$String.iteri; 22 | 23 | var map = $$String.map; 24 | 25 | var mapi = $$String.mapi; 26 | 27 | var trim = $$String.trim; 28 | 29 | var escaped = $$String.escaped; 30 | 31 | var index = $$String.index; 32 | 33 | var rindex = $$String.rindex; 34 | 35 | var index_from = $$String.index_from; 36 | 37 | var rindex_from = $$String.rindex_from; 38 | 39 | var contains = $$String.contains; 40 | 41 | var contains_from = $$String.contains_from; 42 | 43 | var rcontains_from = $$String.rcontains_from; 44 | 45 | var uppercase = $$String.uppercase; 46 | 47 | var lowercase = $$String.lowercase; 48 | 49 | var capitalize = $$String.capitalize; 50 | 51 | var uncapitalize = $$String.uncapitalize; 52 | 53 | var compare = $$String.compare; 54 | 55 | export { 56 | make , 57 | init , 58 | copy , 59 | sub , 60 | fill , 61 | blit , 62 | concat , 63 | iter , 64 | iteri , 65 | map , 66 | mapi , 67 | trim , 68 | escaped , 69 | index , 70 | rindex , 71 | index_from , 72 | rindex_from , 73 | contains , 74 | contains_from , 75 | rcontains_from , 76 | uppercase , 77 | lowercase , 78 | capitalize , 79 | uncapitalize , 80 | compare , 81 | 82 | } 83 | /* No side effect */ 84 | -------------------------------------------------------------------------------- /runtime/stdlib/sys.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import * as Caml_sys from "stdlib/caml_sys.js"; 4 | import * as Caml_exceptions from "stdlib/caml_exceptions.js"; 5 | 6 | var is_js = true; 7 | 8 | var match = Caml_sys.caml_sys_get_argv(/* () */0); 9 | 10 | var big_endian = false; 11 | 12 | var unix = true; 13 | 14 | var win32 = false; 15 | 16 | var cygwin = false; 17 | 18 | var interactive = [false]; 19 | 20 | function set_signal(_, _$1) { 21 | return /* () */0; 22 | } 23 | 24 | var Break = Caml_exceptions.create("Sys.Break"); 25 | 26 | function catch_break() { 27 | return /* () */0; 28 | } 29 | 30 | var argv = match[1]; 31 | 32 | var executable_name = match[0]; 33 | 34 | var os_type = "Unix"; 35 | 36 | var word_size = 32; 37 | 38 | var max_string_length = 2147483647; 39 | 40 | var max_array_length = 2147483647; 41 | 42 | var sigabrt = -1; 43 | 44 | var sigalrm = -2; 45 | 46 | var sigfpe = -3; 47 | 48 | var sighup = -4; 49 | 50 | var sigill = -5; 51 | 52 | var sigint = -6; 53 | 54 | var sigkill = -7; 55 | 56 | var sigpipe = -8; 57 | 58 | var sigquit = -9; 59 | 60 | var sigsegv = -10; 61 | 62 | var sigterm = -11; 63 | 64 | var sigusr1 = -12; 65 | 66 | var sigusr2 = -13; 67 | 68 | var sigchld = -14; 69 | 70 | var sigcont = -15; 71 | 72 | var sigstop = -16; 73 | 74 | var sigtstp = -17; 75 | 76 | var sigttin = -18; 77 | 78 | var sigttou = -19; 79 | 80 | var sigvtalrm = -20; 81 | 82 | var sigprof = -21; 83 | 84 | var ocaml_version = "4.02.3+dev1-2015-07-10"; 85 | 86 | export { 87 | argv , 88 | executable_name , 89 | interactive , 90 | os_type , 91 | unix , 92 | win32 , 93 | cygwin , 94 | word_size , 95 | big_endian , 96 | is_js , 97 | max_string_length , 98 | max_array_length , 99 | set_signal , 100 | sigabrt , 101 | sigalrm , 102 | sigfpe , 103 | sighup , 104 | sigill , 105 | sigint , 106 | sigkill , 107 | sigpipe , 108 | sigquit , 109 | sigsegv , 110 | sigterm , 111 | sigusr1 , 112 | sigusr2 , 113 | sigchld , 114 | sigcont , 115 | sigstop , 116 | sigtstp , 117 | sigttin , 118 | sigttou , 119 | sigvtalrm , 120 | sigprof , 121 | Break , 122 | catch_break , 123 | ocaml_version , 124 | 125 | } 126 | /* No side effect */ 127 | -------------------------------------------------------------------------------- /runtime/utils.js: -------------------------------------------------------------------------------- 1 | // From deno 2 | export function typedArrayToArrayBuffer(ta) { 3 | return ta.buffer.slice(ta.byteOffset, ta.byteOffset + ta.byteLength); 4 | } 5 | -------------------------------------------------------------------------------- /test-examples.sh: -------------------------------------------------------------------------------- 1 | for directory in examples/*/; do 2 | echo "Running example: $directory" 3 | ./reasonable "$directory" 4 | done 5 | --------------------------------------------------------------------------------