David Topham wrote:
"The foreign-function interface allows for call-back functions so there is the mechanism to produce a C function that when called calls an ML function."
in http://stackoverflow.com/questions/17580386/shared-libraries-in-poly-ml
Doesn't this indicate a mechanism that allows an SML function to be called from C?
It is possible with MLton:
http://mlton.org/CallingFromCToSML
with a caveat:
"Unfortunately, MLton?s support for exporting ML functions to C only allows one instance of the function to exist. Thus, we have to keep an ML-side registry of windows and their callback functions, which is used to multiplex the the single instance of the callback."
http://sml3d.cs.uchicago.edu/papers/ml14-sml3d/paper.pdf
This paper is worth reading for its discussion of interfacing OpenGL as well.
- Gergely