The X-Windows/Motif code still builds as far as I'm aware but that's as far as it goes. I would say it was better to use something else through CInterface.
The Poly/ML interactive environment (read-eval-print loop or REPL) is usually the easiest way to develop and test your code. It prints the types and values of top-level expressions. When building an application it is probably easier to use "polyc". This is really a wrapper script for "poly" which compiles, exports and links a stand-alone application. You need to define a function called "main" that is the root function of your application.
$ cat > testme.ML fun main() = print "Hello World\n"; $ polyc testme.ML $ ./a.out Hello World
David Matthews
Thanks for your reply David, I will look into using CInterface. That makes me think that another approach could be to use an imperative
language
for the GUI and link in the ML functions! That way existing GUI
builders
could be used. I will experiment.
I did get the interactive version of the sample Motif code to work OK, but failed to get it to build stand-alone (i.e. using polyc). Perhaps the polyc script doesn't include the needed Motif libraries? But also, my limited understanding of how to incorporate that GUI code into a main function may be to blame. I will keep trying, but after more reading, I am beginning to think that my idea to use the CInterface backwards: calling ML code from C rather than the other way around is not going to work! I had been thinking that instead of wrapping some new GUI library around ML (like the Motif code which seems to be obsolete), I could use existing C/C++ GUI frameworks and have the logic of the program be in ML, but that means calling ML functions from C. Can that be done?
What surprises me is that all these years of people using ML, but no one has felt the need to write stand-alone programs for end-users that have a GUI?
I don't see any example code that does that (I did see Polychrome within a web browser). ...and some examples that mention Isabelle has an IDE -- not PolyML though, just SML/NJ? and with Java required?)
-Dave
On Sat, 13 Dec 2014, David Topham wrote:
...and some examples that mention Isabelle has an IDE -- not PolyML though, just SML/NJ? and with Java required?
Isabelle is centered around Poly/ML, and Scala/JVM plays a special role, too.
Isabelle as an application is mostly self-contained, i.e. practically all its requirements are resolved by the standard distribution from http://isabelle.in.tum.de/. Thus there is little to worry about, if the disk space can be afforded (several 100s MB). You just download and run it on a standard system.
See also http://sketis.net/2014/isabellepide-as-ide-for-standard-ml for a quick start.
Makarius
---------------------------------------------------------------------------- http://stop-ttip.org 1,145,058 people so far ----------------------------------------------------------------------------
Continuing my experiments, I came across sml_tk ( http://www.informatik.uni-bremen.de/~cxl/sml_tk/doc/manual.html) which looks promising. It is also a little old (uses PolyML 4). I ran the Makefile to install it and find it fails trying to do a commit. I noticed that there seems to have been a change in Poly 5.5.2 that removes PolyML.commit). I see in the sml_tk source this line (in poly.sml) : PolyML.comit(); ..so I wonder, what do I replace that with? I see this instruction in Poly v 5 : PolyML.export("mypoly",PolyML.rootFunction);
but that is a precursor to doing a compile? cc -o mypoly mypoly.o -lpolymain -lpolyml
i.e. Those 2 lines replace the idea from v 4 of doing commit?
-Dave
On Sat, Dec 13, 2014 at 9:04 AM, David Topham <dtopham at gmail.com> wrote:
The X-Windows/Motif code still builds as far as I'm aware but that's as
far as it goes. I would say it was better to use something else through CInterface.
The Poly/ML interactive environment (read-eval-print loop or REPL) is usually the easiest way to develop and test your code. It prints the types and values of top-level expressions. When building an application it is probably easier to use "polyc". This is really a wrapper script for "poly" which compiles, exports and links a stand-alone application. You need to define a function called "main" that is the root function of your application.
$ cat > testme.ML fun main() = print "Hello World\n"; $ polyc testme.ML $ ./a.out Hello World
David Matthews
Thanks for your reply David, I will look into using CInterface. That makes me think that another approach could be to use an imperative
language
for the GUI and link in the ML functions! That way existing GUI
builders
could be used. I will experiment.
I did get the interactive version of the sample Motif code to work OK, but failed to get it to build stand-alone (i.e. using polyc). Perhaps the polyc script doesn't include the needed Motif libraries? But also, my limited understanding of how to incorporate that GUI code into a main function may be to blame. I will keep trying, but after more reading, I am beginning to think that my idea to use the CInterface backwards: calling ML code from C rather than the other way around is not going to work! I had been thinking that instead of wrapping some new GUI library around ML (like the Motif code which seems to be obsolete), I could use existing C/C++ GUI frameworks and have the logic of the program be in ML, but that means calling ML functions from C. Can that be done?
What surprises me is that all these years of people using ML, but no one has felt the need to write stand-alone programs for end-users that have a GUI?
I don't see any example code that does that (I did see Polychrome within a web browser). ...and some examples that mention Isabelle has an IDE -- not PolyML though, just SML/NJ? and with Java required?)
-Dave
On Sat, 13 Dec 2014, David Topham wrote:
Continuing my experiments, I came across sml_tk ( http://www.informatik.uni-bremen.de/~cxl/sml_tk/doc/manual.html) which looks promising.
That is a bit less ancient than the X11/Motif stuff, but still very ancient. I would say the oldest GUI framework that still makes some sense is GTK.
Makarius
---------------------------------------------------------------------------- http://stop-ttip.org 1,145,216 people so far ----------------------------------------------------------------------------
On 13 Dec 2014, at 11:04, David Topham <dtopham at gmail.com> wrote:
I could use existing C/C++ GUI frameworks and have the logic of the program be in ML, but that means calling ML functions from C. Can that be done?
I?d humbly suggest you do something like this. Breaking your program along MVC lines (or X11 client/server if you prefer) makes it more robust to changes in UI technology. Makarius?s efforts with jEdit are at least the third mainstream interface that Isabelle has had.
The online documentation for the Poly/ML FFI (foreign function interface) is stale - as you can sort-of infer from the 1994 near the top.
If you read the CINTERFACE.ML file and/or CInterfaceSig.ML you will find all sorts of wonderful things. You want the ?toCfunction? value. This and the rest of the source code that I?ve seen is quite readable, though it might take some experimentation to get your head around how the API is supposed to be used. The old docs are helpful with that.
cheers peter
On 13/12/2014 17:04, David Topham wrote:
I did get the interactive version of the sample Motif code to work OK, but failed to get it to build stand-alone (i.e. using polyc). Perhaps the polyc script doesn't include the needed Motif libraries? But also, my limited understanding of how to incorporate that GUI code into a main function may be to blame.
I've experimented with building a stand-alone executable with Motif and succeeded in getting it to work for me using polyc. (It required building Poly/ML with --with-x). I took the example from http://www.polyml.org/docs/Motif.html and wrapped it up in a function. I did find a problem, though. It looks as though the function has to suspend itself with something like Posix.Process.pause otherwise nothing happens. I seem to recall that the Motif stuff is handled on a separate thread to allow the REPL to continue to accept commands. With a stand-alone application there isn't a REPL so without the "pause" it terminates immediately.
David
open XWindows ; open Motif ;
fun main() = let val shell = XtAppInitialise "" "xed" "Editor" [] [XmNwidth 400, XmNheight 400] ;
val main = XmCreateMainWindow shell "main" [] ;
val bar = XmCreateMenuBar main "bar" [] ;
val fileMenu = XmCreateCascadeButton bar "file" [XmNlabelString "File"] ; val editMenu = XmCreateCascadeButton bar "edit" [XmNlabelString "Edit"] ; val viewMenu = XmCreateCascadeButton bar "view" [XmNlabelString "View"] ; val helpMenu = XmCreateCascadeButton bar "help" [XmNlabelString "Help"] ;
val command = XmCreateText main "command" [XmNeditMode XmSINGLE_LINE_EDIT] ;
val hscroll = XmCreateScrollBar main "hscroll" [XmNorientation XmHORIZONTAL] ; val vscroll = XmCreateScrollBar main "vscroll" [XmNorientation XmVERTICAL] ;
val work = XmCreateDrawingArea main "work" [] ; in
XtManageChildren [fileMenu, editMenu, viewMenu, helpMenu] ; XtManageChildren [bar, command, hscroll, vscroll, work] ;
XmMainWindowSetAreas main bar command hscroll vscroll work ;
XtManageChild main ; XtRealizeWidget shell; Posix.Process.pause() end;