Moscow ML is an open source compiler for the Standard ML programming language.
Questions tagged [mosml]
23 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
3 answers
Is it possible to create a "generic" function in Standard ML?
I would like to create a function remove_duplicates that takes a list of any type (e.g. can be an int list or a bool list or a int list list or a whatever list) and returns the same list without duplicates, is this possible in Standard ML?
user11719516
4
votes
1 answer
Map function on a list in Standard ML
Based on this definition:
An append list is a (simple) implementation of the list abstract data type that makes construction cheap (O(1)), but makes destruction expensive (O(n)). The 'a alistNN and 'a alist types are defined as follows:
datatype 'a…

MasterYork42
- 228
- 2
- 11
4
votes
1 answer
Insert function using foldl/foldr
I have been working on a separate function that returns a list that inserts element x after each k elements of list l (counting from
the end of the list). For example, separate (1, 0, [1,2,3,4]) should return [1,0,2,0,3,0,4]. I finished the function…

bugtester42
- 43
- 3
3
votes
1 answer
SML: What would be the best way to go through a list to take every other value?
I've been doing a lot of practice recently in sml and one problem I've found in my textbook was asking to create a function that applies a function to the odd indexed values in a list. When trying to solve this I don't really understand how to get…

BearsBeetBattlestar
- 318
- 2
- 13
3
votes
1 answer
Is this snippet legal Standard ML according to the Definition?
Is the code snippet given below legal Standard ML according to the Definition? It type-checks with Poly/ML, but not with Moscow ML:
infixr 5 ::: ++
signature HEAP_ENTRY =
sig
type key
type 'a entry = key * 'a
val reorder : ('a -> key) -> 'a…

isekaijin
- 19,076
- 18
- 85
- 153
3
votes
1 answer
How to compile multiple SML files?
How does it work compiling multiple files in Standard-ML? I have 2 files.
file1.sml:
(* file1.sml *)
datatype fruit = Orange | Apple | None
And file2.sml:
(* file2.sml *)
datatype composite = Null | Some of fruit
So as you can see file2.sml is…

Andry
- 16,172
- 27
- 138
- 246
2
votes
2 answers
Evaluation order of let-in expressions with tuples
My old notes on ML say that
let (₁, … , ₙ) = (₁, … , ₙ) in ′
is a syntactic sugar for
(λ ₙ. … (λ ₁. ′)₁ … )ₙ
and that
let (₁, ₂) = ′ in ″
is equivalent to
let = ′ in
let ₂ = snd in
let ₁ = fst in
″
where
each (with or without a…
user20264767
2
votes
1 answer
Finding a value in a function represented environment
When it came to finding a value in a bst env all I had to do was compare the value I was looking for with the root value at a node
type 'a tenv = (name * 'a) btree
exception NotFound of name
fun find compare name Leaf = raise NotFound name
| find…

BearsBeetBattlestar
- 318
- 2
- 13
2
votes
1 answer
Size of propositional-logic formula in Standard ML
I'm working on this problem, where the propositional logic formula is represented by:
datatype fmla =
F_Var of string
| F_Not of fmla
| F_And of fmla * fmla
| F_Or of fmla * fmla
Im trying to write a function that returns the size…

MasterYork42
- 228
- 2
- 11
2
votes
1 answer
"Curry" from tuple in SML
I am trying to define a function wrapper that curries a tuple in SML.
fun curry f = fn (x, y) z => f x y z;
Gives me the error
Non-identifier applied to a pattern.
I am new to ML and not sure why the pattern matching in fn doesn't work.
How…

Kostas
- 4,061
- 1
- 14
- 32
2
votes
3 answers
Writing power function in Standard ML with a predefined compound function
Having trouble writing a power function inStandard Ml. Im trying to write a function called exp of type int -> int -> int.
The application exp b e, for non-negative e, should return b^e.
For example, exp 3 2 should return 9. exp must be…

MasterYork42
- 228
- 2
- 11
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
1
vote
0 answers
How to force garbage collection in Moscow ML
Is there a way to force garbage collection in mosml? I am looking for something similar to SML/NJ's SMLofNJ.Internals.GC.doGC and MLton's MLton.GC.collect. Is it possible in Moscow ML?
Version: mosml 2.10.1

Flux
- 9,805
- 5
- 46
- 92
1
vote
1 answer
Sml tuples length
I was interested in if there is a possible way to get length of tuple in sml?! See example
val tes = ((1,"test"),("test","some"))
Lenght(tes) = 2
I want it for a problem solve there is a problem which says to get students list which contains list…

Mobinkh
- 117
- 1
- 7