What are the limits of type inference?
What are the limits of type inference? Which type systems have no general inference algorithm? ...
What are the limits of type inference? Which type systems have no general inference algorithm? ...
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...
I need to construct an undirected graph. I don't need it to do anything too fancy, but ideally it would work like this: structure UDG = UndirectedGraph val g = UDG.empty val g = UDG.addEdges(g, n1, [n2, n4, n7]) (* n1 is connected to n2, n4, and n7 *) val g = UDG.addEdge(g, n2, n3) UDG.connected(g, n2) (* returns [n1, n3] *) Is there...
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...
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...
I started learning Standard ML recently out of curiosity. So what I know is that is has an efficient compiler (MLton) which allows us to freely use abstractions without worrying about performance. It would be perfect if I could do some GUI programming with Standard ML, too. Is there anything like Gtk, Qt, or WxWidgets binding for Standa...
I'm looking for some kind of "ML for beginners" guide - google has led me to some obscure mailing lists or way-over-my-head texts so far. The problem is, I have zero functional programming experience so far, and wrapping my head around the concepts has turned out far more difficult than expected. For example, the task I'm trying to do n...
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? ...
Is it possible to write functions with dynamically typed input parameters? I tried pattern matching, but apparently it does not work like this. I wish to do something like this: fun firstStr (0,n:string) = n | firstStr (b:string,n:string) = if b>n then n else b; Thank you. ...
I was trying to make a tail-recursive version of this very simple SML function: fun suffixes [] = [[]] | suffixes (x::xs) = (x::xs) :: suffixes xs; During the course of this, I was using type annotations on the paramaters. The following code shows this, and causes a type error (given below), whereas if I simply remove the type annot...
hi, i'm having some trouble with one part of a function. My function needs an input string of at least 3 characters to avoid error, to do this a want to add one or two "." in the var. Looks something like this: fun function(a, b) = if size(a) < 2 then a ^ " " else if size(a) < 3 then a ^ " " if size(b) < 2 then b ^ " " else if size(b)...
Hi all, 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 for up^[[D for left, etc.). While I can still use the system, it makes it very ted...
Currently, my code looks like this: fun gradImage () = let val iImg = Gdimage.image(640,480) (0,0,0); val void = mapi gradient iImg; in Gdimage.toPng iImg "gradient.png" end; mapi is a function with type int*int->int*int*int->image->unit. Essentially it operates on the image supplied. The function looks ug...
I would like to compile my ML program into a executable binary using mosmlc. However, I could not find much information on how to do it. The code that I'd like to compile is here http://people.pwf.cam.ac.uk/bt288/tick6s.sml cx,cy,s,imgLocation are 4 arguments that I'd like to take from command line arguments. For instance, if the progr...
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? ...
I have to write some code in ML and it is my first time I`m going to use the language. Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers for Linux (at most with an interactive console), but no IDE nor Eclipse/NetBeans plugin. An...
Basically, I want to have a function to return a polymorphic function, some thing like this: fun foo () = fn x => x So the foo function takes in a value of type unit and returns a polymorphic identity function and the compiler is happy with that, it gives me: val foo = fn : unit -> 'a -> 'a but once I actually call the foo fu...
I need BFS and DFS sml code. does anyone how should I write it? ...
I need to read file in ML (SLMNJ) and save it in some structures. I need to read some data that points to graph declaration: [( 1 , 2 , 13 ),( 2 , 3 , 3 ),( 2 , 4 , 8 ),( 2 , 5 , 4 ),( 3 , 1 , 5 ),( 3 , 4 , 1 ),( 4 , 6 , 5 ),( 5 , 5 , 5 ),( 6 , 4 , 6 )] (first number: name of the node , secend number: name of connected node , third n...
Hi I need to write SCC algorithm in standard ML. but I don't know how to do that. I have following TYPEs whitch has to be uesd in code: type vertex = int type edge = int * int type graph = (vertex * vertex list) list fun dfs (g: graph) (n: vertex): vertex list = let fun helper (todo: vertex list) (visited: vertex list): vertex ...