Obfuscated error messages

Geoffrey Alan Washburn <[email protected]> Sat, 28 Apr 2007 10:43:42 -0400
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
I'm not really sure if this is a bug, but after restructuring the AST 
for my language a couple weeks ago, SML/NJ has been giving me somewhat 
obfuscated error messages.  For example,

[compiling (iml.cm):m4/../(iml.cm-real):NW/inference-zonk.sml]
m4/inference-zonk.nw:12.1...inference/zonk.nw4:196.4 Error: value type 
in structure doesn't match signature spec
     name: zonkCnstr
   spec:   ?.InferenceZonk.vmap
           -> ?.InferenceSyntax.t -> ?.InferenceSyntax.t 
InferenceMonad.monad
   actual: 'a
           -> ?.InferenceSyntax.t
              -> ?.InferenceSyntax.t InferenceMonad.monad_ex
val it = false : bool
-

For this particular example, it is fine to ignore the "monad_ex" versus 
"monad" distinction because they are just synonyms.  However, I am 
somewhat baffled by SML/NJ reporting the types "?.InferenceSyntax.t". 
The above error is a result of a copy and paste error where I wrote

structure IS = InferenceSyntax
structure M = InferenceMonad

val zonkCnstr: vmap -> IS.Type.t -> IS.Constraint.t M.monad

instead of

val zonkCnstr: vmap -> IS.Constraint.t -> IS.Constraint.t M.monad

But I am baffled as to why SML/NJ chooses to describe both 
InferenceSyntax.Type.t and InferenceSyntax.Constraint.t by 
?.InferenceSyntax.t.  I could understand if it reported 
?.InferenceSyntax.typ and ?.InferenceSyntax.cnstr as that is how they 
are actually defined inside of the structure before 
InferenceSyntax.Type.t and InferenceSyntax.Constraint.t, respectively, 
are defined using the "datatype foo = datatype bar" mechanism.

Is there some programming idiom I could use to help SML/NJ give me more 
informative types in its errors?


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/