Note: The website with server backing is http://89.58.5.223/ (v2202201167307177506.ultrasrv.de).
The goal is to update SOSML to support OCaml.
There are multiple ways to do this:
- Extension:
- Write a OCaml -> SML transpiler for parsing
- Write a postprocessor for the SML output
- A new interpreter
- Use an OCaml interpreter instead of the SML interpreter
- We are closer to the OCaml semantics
- No need to worry about the differences between SML and OCaml
- No transpiler or SML adaptation needed
- We have less control
- We have no full roll-back partial evaluation of code blocks (possible via tricks or toplevel adaptation)
- The OCaml toplevel can be compiled to Javascript using the [js_of_ocaml]http://ocsigen.org/js_of_ocaml/latest/manual/overview) project (Github)
- The cleaner way
- Wrap the toplevel in a way that exposes functions that the SML interpreter uses
- Rewrite the worker to use the (wrapped) OCaml toplevel
- Use the worker in the frontend (here) (no adaptation required)
- The easier way:
- Just ignore the interpreter and worker
- Force the editor to execute its code via the evaluator (transpiled OCaml toplevel)
Differences OCaml and SML:
- Comparison by Andreas Rossberg
- Comparison by Adam Chlipala
- Vectors, StdLib, lazy evaluation, ...
Links:
Information about the SOSML projects:
- The core project SOSML contains the SML logic and the interpreter
- The webworker wrappes the interpreter and exposes it as javascript file that can be included in other projects
- The frontend uses the worker in the editor component
Note:
The npm commands might need export NODE_OPTIONS=--openssl-legacy-provider
.
- StdOut that contains a ppm image is automatically displayed.
- PPM Images need to start with "P3\n[remaining]" or "IMAGE\n[PPM content]"
- Magenta
(1.0,0.0,1.0)
is rendered as transparent
- Shared Libraries like Image with
eval_image ?(wh=(256,256)) name img : ()
are automatically included.
A frontend for SOSML, used by sosml.org, that has different themes (with dark mode support) and allows for saving SML code in the browser.
Node.JS version 8 or higher and NPM version 5 or higher need to be installed on the system. GNU+Linux is recommended.
git clone https://github.com/NeuralCoder3/SOOCaml-frontend.git
To install or(non-exclusive or) update all NPM dependencies run npm i
in the frontend folder.
The frontend can be run locally with npm run start
, this will use a compiled version of the
webworker placed in the frontend/public
server to actually run SML code. To obtain
optimized files suitable for production, use npm run build
to populate tho build
folder. The files in the build
folder are then suitable to be served on a static web
server. (Consult the SOSML-backend repository on how to run a non-static server that
allows for file uploading/sharing.)