-
hello
external imul : int -> int -> int = "Math.imul" [@@bs.val]
-
hey
| A list of languages which compile to JS (Elm, Purescript, OCaml) | |
| (Inspired by this thread: https://groups.google.com/forum/#!topic/elm-discuss/Um7WIBTq9xU) | |
| They all support curry calling convention by default. | |
| Some interesting results: | |
| 1. `min` is curried function, only OCaml(BuckleScript) managed to optimize this overhead. | |
| 2. All optimize the self tail call | |
| 3. Only BuckleScript and PureScript type-specialized comparison functoin (>=) and inlined |
hello
external imul : int -> int -> int = "Math.imul" [@@bs.val]
hey
| let f x y = x + y |
| external to_str : 'a -> string = "js_anything_to_string" | |
| external to_json_string : 'a -> string = "js_json_stringify" | |
| let debug x = print_endline (to_str x ) | |
| let pprint x = print_endline (to_json_string x) | |
| let rec fib = function | |
| | 1 | 2 -> 1 | |
| | n -> fib (n - 1 ) + fib (n - 2) | |
| (** Imperative style *) | |
| let sum n = | |
| let v = ref 0 in |
| git>npm install -g https://github.com/npm-ml/merlin.git | |
| npm ERR! addLocal Could not install /var/folders/df/dh8jkb254qv48cfc0_rhmkf00000gn/T/npm-48145-1a0fbf19/git-cache-3e4efa99/4116bf8bedbaf927784a9d7e05ccd4430bcd7990 | |
| npm ERR! Darwin 15.5.0 | |
| npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "https://github.com/npm-ml/merlin.git" | |
| npm ERR! node v4.2.1 | |
| npm ERR! npm v3.10.5 | |
| npm ERR! code EISDIR | |
| npm ERR! errno -21 | |
| npm ERR! syscall read |
| reason-demo>npm run build | |
| ^[[?25h | |
| > @ build /Users/hongbozhang/git/bucklescript-addons/examples/reason-demo | |
| > source dependencyEnv && bsc -pp ./node_modules/reason/refmt_impl.native -impl hello.re | |
| /Users/hongbozhang/git/bucklescript-addons/examples/reason-demo/node_modules/dependency-env/.bin/dependencyEnv.js:60 | |
| packageName.replace(new RegExp("\-", "g"), function(s){return "_";}).toUpperCase() + "__"; | |
| ^ | |
| TypeError: Cannot read property 'replace' of undefined |
| // Generated CODE, PLEASE EDIT WITH CARE | |
| 'use strict'; | |
| var invalid_argument = /* tuple */[ | |
| 248, | |
| "Invalid_argument", | |
| -3 | |
| ]; |
| // Generated CODE, PLEASE EDIT WITH CARE | |
| 'use strict'; | |
| var invalid_argument = /* tuple */[ | |
| 248, | |
| "Invalid_argument", | |
| -3 | |
| ]; | |
| var not_found = /* tuple */[ |