4

I have the following SML source file with a trivial function in it:

(* fact.sml *)
fun fact_unguarded 0 = 1
  | fact_unguarded n = n * fact_unguarded(n-1)

fun fact 0 = SOME(1)
  | fact n = if n > 0 then SOME(n * fact_unguarded(n-1)) else NONE

I'm trying to compile it with MLTon using the C backend and look at the generated C code.

% mlton -codegen c fact.sml

However, none of the intermediate files are dumped in the current working directory and there appears to be nothing relevant in /tmp either. Is there a way to direct MLTon to either a) produce just the C source file and stop or b) keep intermediate files around even after the final artifact is produced.

% pwd
~/tmp/sml
% ls
fact*       fact.sml
Greg Nisbet
  • 6,710
  • 3
  • 25
  • 65

1 Answers1

4

mlton -stop g -codegen c should do what you want, but due to the way MLton works as a whole-program compiler, there will not be anything left of your functions.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • And there is not. The code seems to be almost entirely stuff related to the MLTon runtime and magical comments describing the ML-side compiler options. – Greg Nisbet Nov 05 '17 at 19:38