Here’s a tiny program:
print_string("Now is the time for all good men to come to the aid of the party\n");
print_newline();
let s = read_line();
print_string("You typed: " ++ s);
print_newline();
Running it produces this (before I get the chance to type anything as input):
jfh$ Node src/Demo.bs.js
Now is the time for all good men to come to the aid of the party
/Users/jfh/.nvm/versions/node/v12.9.0/lib/node_modules/bs-platform/lib/js/caml_external_polyfill.js:16
throw new Error(s + " not polyfilled by BuckleScript yet\n")
^
Error: caml_ml_input_scan_line not polyfilled by BuckleScript yet
at Object.resolve (/Users/jfh/.nvm/versions/node/v12.9.0/lib/node_modules/bs-platform/lib/js/caml_external_polyfill.js:16:11)
at scan (/Users/jfh/.nvm/versions/node/v12.9.0/lib/node_modules/bs-platform/lib/js/pervasives.js:335:38)
at input_line (/Users/jfh/.nvm/versions/node/v12.9.0/lib/node_modules/bs-platform/lib/js/pervasives.js:367:37)
at Object.read_line (/Users/jfh/.nvm/versions/node/v12.9.0/lib/node_modules/bs-platform/lib/js/pervasives.js:431:10)
at Object.<anonymous> (/Users/jfh/foo/repl/src/Demo.bs.js:10:20)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
Because read_line is actually in “Pervasives”, I figured it would probably work. Have I done something wrong? Suggestions for alternative ways to read user input?