Questions tagged [smlnj]

Standard ML of New Jersey (SML/NJ)

SML/NJ is a popular implementation of the Standard ML programming language that was co-developed jointly by Bell Laboratories and Princeton University. It is released under a BSD like license.

References:

Wiki page

866 questions
51
votes
1 answer

SML-NJ, how to compile standalone executable

I start to learn Standard ML, and now I try to use Standard ML of New Jersey compiler. Now I can use interactive loop, but how I can compile source file to standalone executable? In C, for example, one can just write $ gcc hello_world.c -o…
S.J.
  • 1,213
  • 2
  • 12
  • 15
39
votes
1 answer

Warning: calling polyEqual

Can somebody please explain, what does this warning means? stdIn:18.35 Warning: calling polyEqual and why do I have "a and not 'a in the following statement: val alreadyVisited = fn : ''a * ''a list -> bool this is my function: fun…
rookie
  • 7,723
  • 15
  • 49
  • 59
26
votes
3 answers

Line Comments in Standard ML

I'm learning ML, with the SML/NJ dialect. What I'm trying to figure out is if there is a line comment operator. I found the block comment operator, (* ... *), but I really miss line comments. Suggestions? Or am I just stuck with block comments?
icco
  • 3,064
  • 4
  • 35
  • 49
26
votes
2 answers

How to 'fix' the SML/NJ interactive system to use Arrow Keys

I'm having some trouble using SML/NJ interactive system, namely, that when I try to use my arrow keys (either left or right to make a correction in the expression I've typed, up to repeat the last expression), my Terminal prints codes. (e.g. ^[[A…
pablo.meier
  • 2,339
  • 4
  • 21
  • 29
22
votes
6 answers

Unable to determine OS

When I go on terminal (i installed smlnj) and i type sml it gives me the error sml: unable to determine architecture/operating system. What does this mean??? I installed sml like this at this website, but I'm not sure -- are the instructions wrong?
blustone
  • 315
  • 4
  • 13
21
votes
3 answers

Curried anonymous function in SML

I have the function below and it works: (fn x => x * 2) 2; but this one doesn't work: (fn x y => x + y ) 2 3; Can anyone tell me why? Or give me some hint to get it to work?
jjennifer
  • 1,285
  • 4
  • 12
  • 22
20
votes
4 answers

Does SMLNJ have any sort of debugger?

I have looked through the SMLNJ User Guide and can't find anything about debugging capabilities. I'd love to just see a stack trace, or step through a function. Is this possible. Are there other implementations for similar variants of SML that do…
Kai
  • 3,997
  • 4
  • 30
  • 36
18
votes
3 answers

SML: difference between type and datatype

I'm pretty new at SML and I would like to make sure I really know the basics. What is the difference between type and datatype in SML, and when to use which?
Horse SMith
  • 1,003
  • 2
  • 12
  • 25
17
votes
1 answer

Increasing the print depth in SML/NJ

I'm trying to get SML/NJ to print out a result at the top level without putting # signs everywhere. According to some old docs (and a post to this newsgroup on 2001), it should be possible to use Compiler.Control.Print.printDepth However, on SML/NJ…
higherDefender
  • 1,551
  • 6
  • 23
  • 35
17
votes
1 answer

When to use semicolons in SML?

I know that semicolons are used as terminators in REPL. But I'm confused about when to use them in a source file. For example it is not necessary after val x = 1. But if I omit it after use "foo.sml", the compiler will complain about it. Then, what…
Ben
  • 3,612
  • 3
  • 19
  • 24
16
votes
3 answers

Is the SML `o` operator only useful on single-argument functions?

Is the o composition operator (eg. val x = foo o bar, where foo and bar are both functions), only usable on single-argument functions and/or functions with equal numbers of arguments? If not, what is the syntax for, say, composing foo(x,y) with…
GregT
  • 1,300
  • 3
  • 16
  • 25
15
votes
1 answer

How to convert negative integers to strings in SML with minus sign instead of tilde?

The standard SML library function Int.toString prefixes negative numbers with ~ instead of -. Is there a library function to use - instead, short of writing fun i2s i = if i < 0 then "-" ^ Int.toString (~i) else Int.toString i
Jay Lieske
  • 4,788
  • 3
  • 30
  • 41
12
votes
1 answer

How do you print inside a case statement in SML?

I'm just starting out with SML, and I'm trying to modify some code so I understand what it's doing (I can't find a decent SML/NJ debugger, but that's a separate question). fun type_check e theta env non_gens = case e of constant_int _ =>…
Kai
  • 3,997
  • 4
  • 30
  • 36
12
votes
1 answer

SML Warning: Type Vars Not Generalized when using Empty Lists or NONE option

I can't for the life of me figure out why the following SML function is throwing a Warning in my homework problem: fun my_func f ls = case ls of [] => raise MyException | head :: rest => case f head of SOME v => v …
mbear
  • 121
  • 1
  • 6
11
votes
2 answers

Problem running smlnj under OSX 10.6

I downloaded and installed the SML NJ implementation using the DMG for x86 from here : http://smlnj.cs.uchicago.edu/dist/working/110.72/index.html However when I open a terminal window and go to /usr/local/smlnj-110.72/bin and run sml i get a bash…
user671382
  • 111
  • 1
  • 3
1
2 3
57 58