Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ML IDE and Compiler for Windows or Linux or Mac

I have to write some code in ML and it is my first time I`m going to use the language. Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers for Linux (at most with an interactive console), but no IDE nor Eclipse/NetBeans plugin. Any suggestions ?

like image 228
Sajad Bahmani Avatar asked Jan 10 '10 10:01

Sajad Bahmani


People also ask

Is Sublime Text an IDE?

Sublime can be used on Linux, Windows and Mac as an IDE for developing Chromium.


2 Answers

How to Configure SML with Sublime Text 2

For those who prefer Sublime Text instead of Emacs as the editor of choice to program SML, the following guide describes how to configure Sublime Text to work with SML.

For this guide to work for you, you must already have installed smlnj.

Step 1: Install Sublime Text and Package Control

Start by Downloading Sublime Text 2. Make sure to download version 2, because the SML syntax support does not yet work with version 3.

Sublime Text supports an amazing set of packages (i.e. plugins) that you can install separately. One of those packages is called Package Control. You must first Install Package Control to be able to install other packages directly from the editor. The provided link explains what you need to do to install this package.

Step 2: Install SML and Sublime REPL

Now that you have Package Control installed it is going to be really easy to install other packages. There are two packages that we must install now: SML to support syntax highlighting features for the programming language and SublimeREPL which, as you might guess, is a package that adds REPL capabilities for many different programming languages to Sublime Text.

To install these packages you must go to the menu and look for Tools -> Command Palette and type "Install Package". In the search box, you write the name of the package you want to install, select your package from the found list, and hit enter to get it installed. Do this for the two packages mentioned above: "SML" and "SublimeREPL"

Once you have installed the SML package, if you open an SML file you should get syntax highlight capabilities within the editor. It even provides a Sublime Text Theme called Son of Obsidian that you could enable in Preferences -> Color Scheme -> SML -> Son of Obsidian. But you are not required to enable the theme to work with SML, this is just a preference.

Once you have installed the SublimeREPL package you will be able to go to the menu Tools -> SublimeREPL -> SML and open an SML REPL session that will support syntax highlight using the SML package, and command history, line editing and autocompletion. You can make your life really easy if you open two side by side tabs and in your left tab you can have your SML code file and in your right, you SML REPL session. You can do that by using the View -> Layout options.

Step 3: Keyboard Shortcuts

Now let's add a few keyboard shortcuts to work with the REPL. The SublimeREPL package offers little keyboard configuration, and the ones provided are probably not going to work well with the SML REPL. So this is what I typically do.

  • First go to Preferences -> Browse Packages
  • Go into the SublimeREPL/config/SML subfolder.
  • Edit the file Default.sublime-commands in Sublime Text itself. This file contains the current SML menu options within the Tools -> SublimeREPL menu. So, we'll now change it to create a second option that can run an existing file in a new SML REPL session. My edited file looks as shown below. Notice the "id" field. We can define as many different commands as we want, giving them a different ID. In the next step, we'll define what every command does.

    [     {         "caption": "SublimeREPL: SML",         "command": "run_existing_window_command", "args":         {             "id": "repl_sml",             "file": "config/SML/Main.sublime-menu"         }     },     {         "caption": "SublimeREPL: SML - Run File",         "command": "run_existing_window_command", "args":         {             "id": "repl_sml_run",             "file": "config/SML/Main.sublime-menu"         }     }     ] 
  • Now, in the same directory as the previous file, edit the Main.sublime-menu file. This file contains the details of what every command defined above should do. My edited file defines the two commands described above, one to simply open the REPL and one to open the current file in the REPL. It looks as follows:

    [      {         "id": "tools",                 "children":         [{             "caption": "SublimeREPL",             "mnemonic": "r",             "id": "SublimeREPL",             "children":             [{                 "caption": "SML",                 "id": "SML",                 "children": [                     {"command": "repl_open",                      "caption": "SML",                      "id": "repl_sml",                      "args": {                         "type": "subprocess",                         "encoding": "utf8",                         "cmd": ["sml"],                         "cwd": "$file_path",                         "external_id": "sml",                         "syntax": "Packages/SML (Standard ML)/sml.tmLanguage"                         }                     },                     {"command": "repl_open",                      "caption": "SML - Run Current File",                      "id": "repl_sml_run",                      "args": {                         "type": "subprocess",                         "encoding": "utf8",                         "cmd": ["sml", "$file_basename"],                         "cwd": "$file_path",                         "external_id": "sml",                         "syntax": "Packages/SML (Standard ML)/sml.tmLanguage"                         }                     }                 ]                                             }]         }]     } ] 
  • The final step is to add keyboard shortcuts for this two commands. Go to Preferences -> Key Bindings User and edit the file with the following two additional commands. Feel free to change my keys and use whatever other shortcut keys you find appropriate, provided they are not used for other features.

    [     {         "keys":["ctrl+alt+j","k"],          "command": "repl_open",             "args": {              "type": "subprocess",              "encoding": "utf8",              "cmd": ["sml"],              "cwd": "$file_path",              "syntax": "Packages/SML (Standard ML)/sml.tmLanguage",            "external_id": "sml"       }       } ,     {         "keys":["ctrl+alt+j","m"],          "command": "repl_open",             "args": {              "type": "subprocess",              "encoding": "utf8",              "cmd": ["sml", "$file_basename"],              "cwd": "$file_path",              "syntax": "Packages/SML (Standard ML)/sml.tmLanguage",            "external_id": "sml"       }       }   ] 

And we're done. Now, you can open the SML REPL by simply pressing CTRL+J,K (this is press Ctrl+Alt+J, then release keys and press K). And if you are currently working in an SML file, you can press CTRL+J,M to send it to a new SML REPL session.

Step 4: Build System

Sublime Text provides configurations that allow you to parse your code file and determine if something is wrong and let you know exactly where the problem is. In order to do this, we must configure a "build system". The configuration is simply a file that tells sublime text what command to run and how to interpret the output. If sml parser gets to fail to parse or execute your program then the output tells you where the problem is. The build system lets us define a regular expression to parse such output and help Sublime text find the line and column that contains the problem.

Go to Preferences -> Browse Packages and under the User folder create a new file named SML.sublime-build and define the file as follows:

{     "cmd": ["/usr/local/bin/sml","$file"],     "selector": "source.sml",     "working_dir": "$file_path",   "file_regex": "^(.*\\.sml):(\\d+)\\.(\\d+)(\\-(\\d+)\\.(\\d+))?\\s(.*)$"  }  

Make sure to replace the command path with a valid path in your system. Once you have saved the file, you can go to the menu and choose Tools -> Build System -> SML. Then, to check your file, you can do Tools -> Build to parse your file and find any errors. And by using the menu option Tools -> Build Result -> Next Result and Previous Result you can navigate between the errors detected by the build system option and Sublime Text will position the cursor in the exact position of the error as reported by the SML compiler.

My regular expression above might not be the best, so feel free to improve it as you see fit.

And that's it. You're pretty much ready to start coding with SML and Sublime Text.

like image 149
Edwin Dalorzo Avatar answered Sep 22 '22 18:09

Edwin Dalorzo


You can use Isabelle/jEdit as IDE for Isabelle/ML or official Standard ML (SML'97). The underlying ML system is Poly/ML, which is notable for its support for multicore-hardware.

Strictly speaking the Isabelle environment is for interactive and automated theorem proving, but its SML IDE support is quite sophisticated: source files are statically checked and semantically evaluated while the user is editing. The annotated sources contain markup about inferred types, references to defining positions of items etc.

As a quick start, see the Documentation panel, section Examples, entry src/Tools/SML/Examples.thy (as of Isabelle2014).

SML-PIDE

like image 24
Makarius Avatar answered Sep 25 '22 18:09

Makarius