If I write foo.ML:
```` fun main() = PolyML.shell() ````
and compile this with polyc:
```` $ polyc foo.ML -o foo ````
the resulting executable doesn?t give me the usual acknowledgements of my declarations:
```` $ ./foo
3; 4; print "hello\n";
hello
3 + true;
poly: : error: Type error in function application. Function: + : int * int -> int Argument: (3, true) : int * bool Reason: Can't unify int (*In Basis*) with bool (*In Basis*) (Different type constructors) Found near 3 + true Static Errors
````
Here I?d have expected to see lines like `val it = 3 : int`. The behaviour after the compilation of the print call suggests that stdout is live, and that things really are being compiled. The error message after the last interaction is similarly reassuring.
If I call PolyML.main() inside a standard poly shell (a funny thing to do), it does work as expected.
I also tried to write code like that behind PolyML.shell by hand, and though I was providing a CPOutStream TextIO.print, I also failed to see any output from the compiler.
Is there something I should be doing differently?
Michael
What seems to be happening is that the "-q" option from polyc sets the print depth to zero to prevent unnecessary output during compilation. This then gets inherited by the executable. The solution is to set the print depth before starting the shell e.g.
fun main () = (PolyML.print_depth 50; PolyML.shell());
David
On 05/09/2017 17:06, Michael.Norrish at data61.csiro.au wrote:
If I write foo.ML:
fun main() = PolyML.shell()
and compile this with polyc:
$ polyc foo.ML -o foo
the resulting executable doesn?t give me the usual acknowledgements of my declarations:
$ ./foo > 3; > 4; > print "hello\n"; hello > 3 + true; poly: : error: Type error in function application. Function: + : int * int -> int Argument: (3, true) : int * bool Reason: Can't unify int (*In Basis*) with bool (*In Basis*) (Different type constructors) Found near 3 + true Static Errors
Here I?d have expected to see lines like `val it = 3 : int`. The behaviour after the compilation of the print call suggests that stdout is live, and that things really are being compiled. The error message after the last interaction is similarly reassuring.
If I call PolyML.main() inside a standard poly shell (a funny thing to do), it does work as expected.
I also tried to write code like that behind PolyML.shell by hand, and though I was providing a CPOutStream TextIO.print, I also failed to see any output from the compiler.
Is there something I should be doing differently?
Michael
polyml mailing list polyml at inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
Thanks! That?s very helpful.
The next question is in the same setting (my foo executable below).
If I signal SIGINT to this with Control-C I don?t get the normal ?Compilation interrupted? message but instead have the process exit entirely. Do I need to reinstall a signal handler or similar?
Thanks, Michael
On 6/9/17, 13:02, "David Matthews" <David.Matthews at prolingua.co.uk> wrote:
What seems to be happening is that the "-q" option from polyc sets the print depth to zero to prevent unnecessary output during compilation. This then gets inherited by the executable. The solution is to set the print depth before starting the shell e.g.
fun main () = (PolyML.print_depth 50; PolyML.shell());
David
On 05/09/2017 17:06, Michael.Norrish at data61.csiro.au wrote: > If I write foo.ML: > > ```` > fun main() = PolyML.shell() > ```` > > and compile this with polyc: > > ```` > $ polyc foo.ML -o foo > ```` > > the resulting executable doesn?t give me the usual acknowledgements of my declarations: > > ```` > $ ./foo >> 3; >> 4; >> print "hello\n"; > hello >> 3 + true; > poly: : error: Type error in function application. > Function: + : int * int -> int > Argument: (3, true) : int * bool > Reason: > Can't unify int (*In Basis*) with bool (*In Basis*) > (Different type constructors) > Found near 3 + true > Static Errors > > ```` > > Here I?d have expected to see lines like `val it = 3 : int`. The behaviour after the compilation of the print call suggests that stdout is live, and that things really are being compiled. The error message after the last interaction is similarly reassuring. > > If I call PolyML.main() inside a standard poly shell (a funny thing to do), it does work as expected. > > I also tried to write code like that behind PolyML.shell by hand, and though I was providing a CPOutStream TextIO.print, I also failed to see any output from the compiler. > > Is there something I should be doing differently? > > Michael > > _______________________________________________ > polyml mailing list > polyml at inf.ed.ac.uk > http://lists.inf.ed.ac.uk/mailman/listinfo/polyml >
Yes. The code that calls PolyML.shell in the original root function is in TopLevelPolyML.sml. See https://github.com/polyml/polyml/blob/e7a662f8f9c4fc8ee8046a35372a356e3635e0...
The signal handler is set a few lines above that.
David
On 06/09/2017 15:03, Michael.Norrish at data61.csiro.au wrote:
Thanks! That?s very helpful.
The next question is in the same setting (my foo executable below).
If I signal SIGINT to this with Control-C I don?t get the normal ?Compilation interrupted? message but instead have the process exit entirely. Do I need to reinstall a signal handler or similar?
Thanks, Michael
On 6/9/17, 13:02, "David Matthews" <David.Matthews at prolingua.co.uk> wrote:
What seems to be happening is that the "-q" option from polyc sets the print depth to zero to prevent unnecessary output during compilation. This then gets inherited by the executable. The solution is to set the print depth before starting the shell e.g. fun main () = (PolyML.print_depth 50; PolyML.shell()); David On 05/09/2017 17:06, Michael.Norrish at data61.csiro.au wrote: > If I write foo.ML: > > ```` > fun main() = PolyML.shell() > ```` > > and compile this with polyc: > > ```` > $ polyc foo.ML -o foo > ```` > > the resulting executable doesn?t give me the usual acknowledgements of my declarations: > > ```` > $ ./foo >> 3; >> 4; >> print "hello\n"; > hello >> 3 + true; > poly: : error: Type error in function application. > Function: + : int * int -> int > Argument: (3, true) : int * bool > Reason: > Can't unify int (*In Basis*) with bool (*In Basis*) > (Different type constructors) > Found near 3 + true > Static Errors > > ```` > > Here I?d have expected to see lines like `val it = 3 : int`. The behaviour after the compilation of the print call suggests that stdout is live, and that things really are being compiled. The error message after the last interaction is similarly reassuring. > > If I call PolyML.main() inside a standard poly shell (a funny thing to do), it does work as expected. > > I also tried to write code like that behind PolyML.shell by hand, and though I was providing a CPOutStream TextIO.print, I also failed to see any output from the compiler. > > Is there something I should be doing differently? > > Michael > > _______________________________________________ > polyml mailing list > polyml at inf.ed.ac.uk > http://lists.inf.ed.ac.uk/mailman/listinfo/polyml >
polyml mailing list polyml at inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml