Resources
Standard ML
Standard ML is a safe, modular, strict, functional, polymorphic programming language with compile-time type checking and type inference, garbage collection, exception handling, immutable data types and updatable references, abstract data types, and parametric modules. It has efficient implementations and a formal definition with a proof of soundness.
For more information:
- What is SML?
- User's guide to SML , including information on downloading SML.
- The Standard ML Basis Library
Recommended gentle introductions:
- A Gentle Introduction to ML, by Andrew Cumming, Computer Studies, Napier University, Edinburgh
- Tips for Computer Scientists on Standard ML, by Mads Tofte, Department of Computer Science, University of Copenhagen (20 pages)
Recommended books and other documents:
- Programming in Standard ML, Robert Harper
- ML for the Working Programmer (2nd edition), Larry Paulson, Cambridge University Press,1996, ISBN (hardback):0-521-57050-6, ISBN (paperback):0-521-56543-X
- Information on SML including tutorials
Performance comparison between C++, Java, OCaml, SML
For an interesting recent comparison between programming languages see the Ray tracer language comparison. Some older articles:
- Why functional programming matters, John Hughes
- Why no-one uses functional languages", Phil Wadler
- Haskell vs Ada vs C++ vs Awk vs ..: An Experiment in Software Prototyping Productivity, Paul Hudak and Mark Jones
- Functional Programming for the real world , Rowan Davies
Programming Contests
Once you have mastered SML, you may be intrigued by the ICFP Programming contest held every year. Check it out here! Note that this contest does not require you to program in a functional language, but nevertheless many people choose a functional language.
Using SML in emacs or xemacs:
Documentation for sml-mode
Files for sml-mode (sml-mode)
Instructions:
Copy the files for sml-mode into your load-path:
/home/user/yourname/yourdir/
Then, add the following into your emacs or xemacs init.el file:
;; SML Mode
;; ============================
(setq load-path (cons "/home/user/yourname/yourdir" load-path))
(autoload 'sml-mode "sml-mode" "Major mode for editing SML." t)
(setq sml-mode-info "~/yourdir/sml-mode/sml-mode.info")
(setq auto-mode-alist
(append '(("\\.cm$" . sml-mode)
("\\.fun$" . sml-mode)
("\\.sml$" . sml-mode)
("\\.sig$" . sml-mode)
("\\.ML$" . sml-mode)) auto-mode-alist))
(add-hook 'sml-load-hook '(lambda () (require 'sml-font)))
(defun delete-gc-message ()
(beginning-of-line 0)
(if (looking-at ".*\\(GC #[0-9]+[\.[0-9]+]*: *([0-9]* ms)\C-m*\n\\)")
(delete-region (match-beginning 1) (match-end 1))))
(defun comint-filter-sml-gc-messages (foo)
(save-excursion
(goto-char comint-last-output-start)
(delete-gc-message)))
(add-hook 'inferior-sml-mode-hook
(lambda ()
(add-to-list 'comint-output-filter-functions
'comint-filter-sml-gc-messages)))
How to use SML within emacs or xemacs:
- Start emacs or xemacs (ideally in the directory where your sml-code resides)
- Load a sml-file.
- Type M-x sml. This will start a "sml" process in the background.
- Switch to buffer *sml*. Now you can start programming within emacs or xemacs.
How to change the printing depth in SML 110.55?
If you want to print back the results of some evaluation and you only see # where you expect some expression, then you may want to change the print depth of the sml compiler.
Control.Print.printDepth controls the printing depth.
Control.Print.printDepth := 100;
will set it to 100.
Control.Print.printLength controls the printing length.
Control.Print.printLength := 100;
will set it to 100.
Alternatively, you can set the depth at startup using the -Cxxx=yyy command line switch: sml -Cprint.depth=100 Run sml -H to see a list of all such options.