Search code examples
emacsorg-modesml

SML in org-mode block returns it = "stdIn" : string


When I start an SML REPL and put in

print("floor is : " ^ (Int.toString (floor 3.1823)) ^ "\n");

I get

floor is : 3
val it = () : unit

i.e., expected behavior. But when I do the same thing in an Emacs org-mode source block:

#+name: sml_test
#+begin_src sml :exports both
print("floor is : " ^ (Int.toString (floor 3.1823)) ^ "\n");
#+end_src

I get the cryptic (for me)

#+RESULTS: sml_test
: val it = "stdIn" : string

Does anyone from the ML world know what this could mean?


Solution

  • This is probably a bug in ob-sml. If you visit the *sml* buffer, and do C-c C-c on the source block, the sml REPL gets this input:

    print("floor is : " ^ (Int.toString (floor 3.1823)) ^ "\n");
    ; "stdIn";
    

    Note the extra "stdIn" there. Also if you set :results output on the block, you should get the standard output of the block, but I get the same thing as with the default :results value setting (and the same thing you get: the cryptic thing which I guess is the result of that spurious "stdIn" - I should say that I know nothing about ML, so take all this with the appropriately sized grain of salt). I would open an issue on the ob-sml github project.