If the following is foo.ML:
fun doit () = let fun recurse i = case TextIO.inputLine TextIO.stdIn of NONE => () | SOME l => (print (Int.toString i ^ ": " ^ l); recurse (i + 1)) in recurse 1 end;
PolyML.export("mytest", doit);
and I then do
$ poly < foo.ML $ cc -o mytest mytest.o -lpolymain -lpolyml $ echo "hello, world" | ./mytest
I get
1: 2: hello, world
as output.
This is with a polyml 5.5.2 just downloaded from Sourceforge and configured with --enable-shared. I'm pretty sure this used to work (a minor feature of the HOL4 build process depended on it).
Michael