Questions tagged [mlton]

MLton is an open source, whole-program optimizing compiler for the Standard ML programming language.

MLton aims to produce fast executables, and to encourage rapid prototyping and modular programming by eliminating performance penalties often associated with the use of high-level language features.

MLton development began in 1997 and continues with a worldwide community of developers and users, who have helped to port MLton to a number of platforms.

22 questions
8
votes
1 answer

Compiling SML projects from multiple files

I've got a project with many files in it and I want it to work with most popular compilers. Unfortunately, PolyML and SML/NJ require use statements, while MosML additionally requires explicitly loading basis library structures using load, which is…
zlotnleo
  • 275
  • 2
  • 12
5
votes
2 answers

Horner's rule for two-variable polynomial

Horner's rule is used to simplify the process of evaluating a polynomial at specific variable values. https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#Standard_ML I've easily applied the method using SML, to a one variable…
4
votes
1 answer

mlton view intermediate C file when using `-codegen c`

I have the following SML source file with a trivial function in it: (* fact.sml *) fun fact_unguarded 0 = 1 | fact_unguarded n = n * fact_unguarded(n-1) fun fact 0 = SOME(1) | fact n = if n > 0 then SOME(n * fact_unguarded(n-1)) else NONE I'm…
Greg Nisbet
  • 6,710
  • 3
  • 25
  • 65
2
votes
1 answer

Handling and printing exceptions with SML

I have a code that looks quite like: ignore (f ()) handle AssertionError msg => (print ("assertion error: " ^ msg ^ "\n"); ()) | _ (* other exceptions *) => (print ("exception raised\n"); ()) But I need to print the generic…
2
votes
1 answer

Mlton compiler not working (not giving any output)

Installed the MLton compiler on Ubuntu (sudo apt-get install mlton) and had no problems (seemingly) with installation. When I try to use it (e.g. "mlton test.sml") it sits for a second and then returns nothing. If I try to print something in the…
P. Davis
  • 33
  • 1
  • 5
2
votes
0 answers

MLton on Alpine Linux

I am encountering problems to install and run the MLton compiler in a Docker container using Alpine Linux. Is there a way to install this compiler on this system? Try #1 Using the standard `alpine base image and the binary distribution of MLton: $…
Alban Linard
  • 1,037
  • 9
  • 19
2
votes
1 answer

Exit process using both MLton and MosML (Process module missing)

I am trying to write code that will compile on either mlton or mosml. In my mosml I can exit on failure as follows. Process.exit(Process.failure) However when I try to reuse the same code and compile on mlton. It cannot find Process in its library…
henninb
  • 133
  • 2
  • 11
2
votes
1 answer

Dependent signature specialization

Can I specialize a type in a signature using types before that type and in the signature? Here is an example: signature A = sig type t type s end Can I specialize A by the following? signature B = A where type s = t list Both SML/NJ and Mlton…
Peng Wang
  • 93
  • 4
2
votes
1 answer

Is there any way to compile Standard ML to JavaScript taking advantage of MLTon?

The only way I could imagine would be using Emscripten, but MLTon has no LLVM backend. Is it possible somehow?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
2
votes
1 answer

define type before use

According to the MLton documentation: Standard ML requires types to be defined before they are used. [link] Not all implementations enforce this requirement (for example, SML/NJ doesn't), but the above-linked page makes a good case for why it…
ruakh
  • 175,680
  • 26
  • 273
  • 307
1
vote
2 answers

How to convert SML/NJ HTML4 representation to a string

When using SML/NJ library's HTML4 library, how do I convert the Standard ML representation of HTML4 into a string? For example, if I have the HTML representation below, what function can I use to get a string similar to…
Flux
  • 9,805
  • 5
  • 46
  • 92
1
vote
1 answer

How to wait for Concurrent ML threads to finish before exiting program?

I am attempting to implement a basic 'stress testing' program in MLton and its Concurrent ML implementation, specifically the Monte Carlo Pi test described here. While I think I have most of what I need figured out, I have a problem in that my…
Jarak
  • 972
  • 9
  • 16
1
vote
2 answers

Polymorphic coersion to Word64 in Standard ML

I would like create a polymorphic function that converts 8,16,32 bit words into 64 bit word. How can I do it? UPDATE1 In the basis library all word structures have functions toLarge and fromLarge to convert to/from the LargeWord, which is as far as…
xafizoff
  • 398
  • 1
  • 13
1
vote
2 answers

Force equality for real numbers in Real in SML

As explained in the REAL signature, real type defined in SML is not an equality type and hence the following expression does not reduces > 1.0 = 1.0; poly: : error: Type error in function application. Function: = : ''a * ''a -> bool Argument:…
1
vote
1 answer

MLton compile statically

I've got an issue with the compilation of a program in Standard ML. This program is working perfectly and compiling perfectly on my local machine. But I would like to be able to compile it statically in order to execute it somewhere else on a…
Valentin Montmirail
  • 2,594
  • 1
  • 25
  • 53
1
2