Mlton looks at intermediate C file using `-codegen c`

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 am trying to compile it using MLTon using a C server 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 appear to /tmpbe of no significance. Is there a way to direct MLTon to: a) create only the original C file and stop it, or b) save intermediate files even after creating the final artifact.

% pwd
~/tmp/sml
% ls
fact*       fact.sml
+4
source share
1 answer

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

+4

Source: https://habr.com/ru/post/1688768/


All Articles