[MLton] bug? pattern-matching against value-carrying constructors
William Lovas
wlovas@cs.cmu.edu
Thu, 21 Jul 2005 00:57:59 -0400
Hey MLton guys,
I've found some counterintuitive behavior in MLton's handling of a probable
error condition. The problem occurs when you try to pattern match against
a value-carrying data constructor without giving it an argument. A simple
one-line example is this:
fun f x = case x of SOME => true | _ => false
When i try to compile this program with MLton 20041109, i get a 12898-line
error message ending with "unhandled exception: TypeError". Is this a bug?
For what it's worth, i was trying this program out to see how various
compilers handled it. SML/NJ seems to have sensible behavior:
Standard ML of New Jersey v110.54 [built: Wed Jun 1 18:17:08 2005]
- fun f x = case x of SOME => true | _ => false;
stdIn:1.11-1.46 Error: data constructor SOME used without argument in
pattern
Andreas Rossberg's HaMLet *might* be what the Definition calls for, but
it's very counterintuitive in my opinion:
HaMLet 1.2 - To Be Or Not To Be Standard ML
[loading standard basis library]
- fun f x = case x of SOME => true | _ => false;
val f = <fn> : ('a -> 'a option) -> bool
And i have no idea what MLton's doing, but it looks like a lot :)
William
P.S. Thanks for your help on our query regarding time limiting computations
for this year's ICFP contest! We ended up using Engine.timeLimit directly
in our submission, and it did the job quite effectively.