SOSML is an online interpreter for the functional programming language Standard ML, written in TypeScript. It is to be used as a learning tool in a freshman class at Saarland University; you can try it out at https://sosml.github.io.
Correctly lexing, parsing, elaborating and interpreting any SML core language program, i.e. a program that may contain the following constructs:
- Supported declarations (partially supported declarations in italics)
- value declarations (
val x = 42;) - function declarations (
fun f 0 = 42 | f x = f (x-1);) - type alias declarations (
type t = 'a -> (int * int)) - datatype declarations (
datatype tree = T of tree list;)withtypewill not be supported.
- abstract datatype declarations (
abstype tree = T of tree list with val empty = T [];) Note thatabstypeis implemented as a derived form as proposed by Successor ML.withtypewill not be supported.
- exception declarations (
exception E of int;) - local declarations (
local val x = 42; in val y = x + 2; end;) - declaring operators as infix, nonfix, left, and right associative via
infix,infixr, andnonfix -
opendeclarations - structure declarations (
structure S = struct end;) - signature declarations (
signature S = sig end;) - functor declarations (
functor F = struct end;)
- value declarations (
- Supported expressions (This list is non-exhaustive)
- tuple (
(1, 2, 3)), records ({a = 1, b = 2}), and lists ([1, 2, 3]) - application expressions (
f x) - infix expressions (
3 + 4 - 5 * 6) -
andalsoandorelseexpressions -
raiseandhandleexpressions - conditionals (
if true then 2 else 3) - case analyses (
case x of 0 => 0 | _ => 1) - abstractions (
fn 0 => 0 | _ => 1) -
whileloops -
print -
ref,!, and:= - structures
- signatures
- functors
- tuple (
- Supported standard library constructs (Note that all available libraries are loaded per default, currently SOSML has not implemented any user-space loading of modules.)
- Math library
- Char library
ord,chr,Char.isLower,Char.isUpper,Char.isDigit,Char.isAlpha - Int library
Int.minInt,Int.maxInt, andInt.compare - Real library
Real.compare,Real.fromInt,Real.round,Real.floor, andReal.ceil - Option library
- List and Listsort libraries
- Vector library
fromList,tabulate,length,sub,update,app,map,foldl,foldr - Array library
fromList,tabulate,length,sub,update,vector,foldl,foldr - String library
The dependencies of this package must be installed to test or build.
npm installTo build the interpreter and pack it into one file using Webpack run:
npm run buildThis will create a file in the directory build called interpreter.js.
To also minify the result run:
npm run distThis will create a file in the directory build called interpreter.min.js.
To run the tests use:
npm testThis runs all tests located in the test directory.
We welcome you to open an Issue for any error you may find, and we will try to fix it ASAP. Further, if you want additional parts of the Standard Library or other features in general implemented, feel free to open a new Issue.
If you want to contribute via writing code, you may check the Issues page for any unresolved problems or unimplemented features and then submit a pull request after solving that problem or implementing that feature.