Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:07:27+00:00 2026-05-20T05:07:27+00:00

I start to learn Standard ML, and now I try to use Standard ML

  • 0

I start to learn Standard ML, and now I try to use Standard ML of New Jersey compiler.

Now I can use interactive loop, but how I can compile source file to standalone executable?

In C, for example, one can just write

$ gcc hello_world.c -o helloworld

and then run helloworld binary.

I read documentation for SML NJ Compilation Manager, but it don`t have any clear examples.

Also, is there another SML compiler (which allow standalone binary creating) available?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:07:28+00:00Added an answer on May 20, 2026 at 5:07 am

    Both MosML and MLton also have the posibility to create standalone binary files. MosML through mosmlc command and MLton through the mlton command.

    Note that MLton doesn’t have an interactive loop but is a whole-program optimising compiler. Which in basic means that it takes quite some time to compile but in turn it generates incredibly fast SML programs.

    For SML/NJ you can use the CM.mk_standalone function, but this is not advised in the CM User Manual page 45. Instead they recommend that you use the ml-build command. This will generate a SML/NJ heap image. The heap image must be run with the @SMLload parameter, or you can use the heap2exec program, granted that you have a supported system. If you don’t then I would suggest that you use MLton instead.

    The following can be used to generate a valid SML/NJ heap image:

    test.cm:

    Group is 
            test.sml
    
            $/basis.cm
    

    test.sml:

    structure Test =
    struct
    
    fun main (prog_name, args) =
        let
          val _ = print ("Program name: " ^ prog_name ^ "\n")
          val _ = print "Arguments:\n"
          val _ = map (fn s => print ("\t" ^ s ^ "\n")) args
        in
          1
        end
    end
    

    And to generate the heap image you can use: ml-build test.cm Test.main test-image and then run it by sml @SMLload test-image.XXXXX arg1 arg2 "this is one argument" where XXXXX is your architecture.

    If you decide to MLton at some point, then you don’t need to have any main function. It evaluates everything at toplevel, so you can create a main function and have it called by something like this:

    fun main () = print "this is the main function\n"
    
    val foo = 4
    
    val _ = print ((Int.toString 4) ^ "\n")
    
    val _ = main ()
    

    Then you can compile it by mlton foo.sml which will produce an executable named “foo”. When you run it, it will produce this as result:

    ./foo 
    4
    this is the main function
    

    Note that this is only one file, when you have multiple files you will either need to use MLB (ML Basis files) which is MLtons project files or you can use cm files and then compile it by mlton projectr.mlb

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learned php as functional and procedure language. Right now try to start learn
I want to make a smart keyboard that can learn and save new words
I have just start to learn wpf. Can anybody clear me the following to
I'm trying to learn how to use the Control.Parallel module, but I think I
When I start to learn a new language, I always feel like I'm not
I start to learn asm using fasm, unfortunately after compile code below I get
I'm a little bit confused. I want to start learn Flex3 with Eclipse and
I start to learn class in PHP. According to my experience with other language,
I am looking to start from scratch to learn to program embedded systems. After
I wanted to learn C, so I decided to start a C project and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.