smlnj

prototyping functions in SML

I have two functions, f and g, which call each other recursively. Unfortunately, when f calls g, it has not yet been declared, so I get an "unbound variable" error. How can I prototype (or whatever the equivalent vocabulary is) this function in SML/NJ? ...

How do I use the Queue library in SML/NJ

I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ? ...

What is a good book or tutorial on Standard ML?

What is a good book or tutorial on Standard ML? ...

SML comparing files at the bit level

I am attempting to compare files in a directory using SML. Using the TextIO library is fairly easy but I need to compare the files at the bit level. That is, a binary compare. I am using a function similar to this: fun listDir (s) = let fun loop (ds) = (case OS.FileSys.readDir (ds) of "" => [] before OS.FileSys.closeDir (ds)...

smlnj listdir

Hi, i am a newbie learning sml and the question i am thrown with involves IO functions that i have no idea how it works even after reading it. Here is the 2 questions that i really need help with to get me started, please provide me with codings and some explaination, i will be able to trial and error with the code given for the other q...

smlnj rephrased question for listdir(filename, directoryname)

Hi, i am a newbie learning sml and the question i am thrown with involves IO functions that i have no idea how it works even after reading it. Here is the 2 questions that i really need help with to get me started, please provide me with codings and some explaination, i will be able to trial and error with the code given for the other qu...

Reading lines and puting them into a list

The following question is related SMLNJ. I am trying to write a function that when called, the text file would be read and each line will be placed into a list. I kept geting some syntax errors, could someone help me debug it please? The following is the code i have: fun readlist(infile: string) = let val ins = TextIO.openIn infi...

Looping over lines of a text file in SML/NJ

I have this SML/NJ code that reads a single line from a text file and then it will return a list for me, but I am having trouble making it do the same thing to every single line and stop when there are no more lines. Can anyone please help me by giving me a looping sample here? fun readlist(infile : string) = let val ins = TextIO.openIn...

How can I customize the SML/NJ interactive loop?

I'm new to Standard ML and I'm trying to get my head around the SML/NJ runtime environment. I want to adapt it to my needs. Specifically, I want to: Use IntInf by default Prevent it from truncating strings and IntInf to 70 characters. Here's what I've found in my 8+ hours reading documentation and experimenting. I can overload IntIn...

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 _ => (integer,theta) | constant_bool _ => (boolean,theta) | ... Assume this is valid co...

How to coerce a type in SML (like casting)

I'm creating a structure of Rationals (int * int) and one of my functions is: fun diff ((n, d), (n', d')) = let val (top, bot) = sum ((n, d), (~n', d')) in (top / gcd(top, bot), bot / gcd(top, bot)) end gcd gives me the greatest ...

SML function call doesn't parse arguments as arguments

I'm getting what seems to be a precedence issue in calling an SML function, substitute: fun substitute v new (typevar q) = ... And I am calling this from another function: fun new_type_vars (typevar v) non_gens = substitute v new_var() (typevar v) But I get an error: C:/sml/type_checker.sml:22.48-23.44 Err...

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 provide this feature? ...

How do I print type information in SML?

After a command is executed in SML, "it" is returned which has the data and the type returned from the command. For example: false; val it = false : bool Let's say I have a binding in a program like so: val argsToOutput = (map (fn (Absyn.var_exp(n)) => (lookupReference env n)) exps) Is there a w...

Using ML in "Real-World" Applications

I really liked learning ML at college. I find functional programming often a refreshingly elegant way to write certain algorithms. I have heard of F# and played around with that a bit. Still, I've written some interesting functions in ML and would like to integrate them as libraries I could use in other applications. Usually I paste ...

BigInt for Standard ML/NJ

Is there a Java BigInt equivalent for Standard ML? The normal int type throws an exception when it overflows. ...

Suppress "val it" output in Standard ML

I'm writing a "script" in Standard ML (SML/NJ) that sets up the interactive environment to my liking. The last thing the script does is print out a message indicating everything went smoothly. Essentially, the last line is this: print "SML is ready.\n"; When I run the script, all goes well but the SML interpreter displays the return v...

Is there a way to get a Curried form of the binary operators in SML/NJ?

For example, instead of - op =; val it = fn : ''a * ''a -> bool I would rather have - op =; val it = fn : ''a -> ''a -> bool for use in val x = getX() val l = getList() val l' = if List.exists ((op =) x) l then l else x::l Obviously I can do this on my own, for example, val l' = if List.exists (fn y => x = y) l then l else x::l...

Signature inside of a structure

I want to place signature/structure pair inside a structure, like so: structure Outer :> OUTER = struct signature INNER = sig ... end structure Inner :> INNER = struct ... end end but even the simplest of examples produces an error: ../test.sml:1.18-2.6 Error: syntax error: replacing STRUCT with...

IDE's for Standard ML of New Jersey

I'm having to write a whole bunch of SML code this coming week so I was hoping if anyone knew: A good Standard ML IDE? Or a good text editor for Linux that has code-highlighting for SML? I know Geany and Gedit don't. If you work with SML, what do you use? ...