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开发者_StackOverflow社区 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 ?
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.
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).
When working with SML on Windows, I've been using SML/NJ for compiling and Notepad++ for editing (Notepad++ has syntax coloring for Caml, which should be identical to SML for your needs).
As mentioned, for ML a simple editor should be enough.
For SML a few Emacs modes exist. Check http://mlton.org/Emacs for more information.
The sml-mode should provide you a good environment for writing SML code. Eclipse & Co. were developed due to the fact that java requires a lot of boilerplate stuff like accessors, adapters and so on. If you require same features for ML then you should double-check whether you are not over-engineering.
Edit: and by the way, SMLNJ ships with an eclipse plugin. I can't post a link though, just google for smlnj eclipse .
I'm developing Scheme IDE for Windows. It's called "Babbage" . It has also mode for OCaml and SML. It is like a minimum Emacs. Babbage is very simple and has windows like key assign. Babbage is Unicode editor.
http://homepage1.nifty.com/~skz/Entry/babbage.html
Eclipse can be set up to get much useful functionality, without having an sophisticated specific language plug-in.
I maintain a guide for setting up Eclipse for new languages. Some highlights from that document:
Syntax colors can be added with either the Eclipse Colorer. They are plug-ins that provides syntax colors for a large number of languages, including SML and OCaml. New languages can be added easily using custom color files.
To build using an external compiler from inside Eclipse the standard Program Builder feature can be used. The builder is run when the normal Build Project command is issued. To set up a new builder: Project Properties -> Builders -> New... -> Program or use the Laid Build Marker plug-in below.
To capture compile errors and warning from an external builder a build output parser can be used. Laid Builder Marker is a plug-in that implements such parsers. The parsers put problem markers in editors and in the Problems view. This plug-in can also be used to add Program Builders to projects. The builder for Cabal can be used as a starting point.
To run compiled programs from inside Eclipse the use the External Tools feature. (Run -> External Tools)
Extended support for code navigation and text selection can be added with some of the other Laid Project plug-ins: The Marker Block Selection plug-in can be used to select text enclosed be brackets. The Editor Utilities plug-in can be used to, among other things, jump between blocks of code delimited by blank lines.
Use the standard Word Completion command (Shift+Alt+7) as a poor person's content assist.
Use the standard Toggle Block Selection command (Shift+Alt+A) to insert/remove line comments on multiple lines at the same time.
Some other useful standard Eclipse features include:
- The Open Resource command (Ctrl+Shift+R)
- The File Search command (Ctrl+H)
- The Bookmarks feature (Edit -> Add Bookmark). Make sure to check Include in next/prev navigation box (Preferences -> General -> Editors -> Text Editors -> Annotations -> Bookmarks).
Update site for the Laid project:
https://bitbucket.org/lii/laid_language_tools/src/master/se.lidestrom.laid.update_site/
Update site for Eclipse Colorer:
http://colorer.sourceforge.net/eclipsecolorer/
Disclaimer: I am the author of the Laid project.
精彩评论