[MLton-user] StringCvt.cs int'ness is not visible.
Raymond Racine
rracine@adelphia.net
Tue, 02 Nov 2004 20:41:55 -0500
structure Test =
struct
structure BT = RegExpFn (structure P = AwkSyntax structure E =
BackTrackEngine)
val sregex = "A.C"
val cregex = BT.compileString sregex
val line = "ABCDEFG"
fun test n = let val matches = StringCvt.scanString (BT.find cregex)
line
val tree = Option.valOf matches
in
case MatchTree.nth(tree,n) of
NONE => "0"
| SOME {len,pos} => Int.toString (pos) (* or
String.substring (line,pos,len)*)
end
end
val _ = print (Test.test 0)
============================================
This works in SML/NJ and fails to compile in MLTON.
It appears that the StringCvt.cs int'ness is hidden.
The RegExpFn, I think, hides it so you can't use the returned
StringCvt.cs as in int in MatchTree calls.
This uses SML/NJ's Util/RegExp stuff which I copied over.
To get it to work I changed in MLton's STRING_CVT from:
type cs
to type cs = int
I am not saying this is a proper solution, just a solution.
But it does seem that unless one can see StringCvt.cs as an int (which
is how its defined in the StringCvt structure), then it is a bit
useless.
Ray