Re: debuggin types in records

Vesa Karvonen <vesa.karvonen-bbCR+/[email protected]> Fri, 26 Jan 2007 08:48:47 +0200
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
Quoting brian <briand-/[email protected]>:

> I ran across the rather self-explanatory error
> 
>    operator domain: XEventTypes.key_xevtinfo
>    operand:         {child:word, event:word, event_pt:Geometry.point,
>                      keycode:int, mbut_state:XProtTypes.mbutton_state,
>                      mod_state:XProtTypes.modkey_state, root:word,
>                      root_pt:Geometry.point, same_screen:bool,
>                      time:Word32.word}
> 
> The problem is that I _think_ the error is due to the fact that I've  
> got the type of one of the entries wrong.
[...]
> Any good stratgey for figuring this out ?

Improve SML/NJ to give better error messages.

For example, given the code

  val mono = ref {a=1, b=true, c=""}
  val error = mono := {a=1, b=0, c="1"}

MLton gives the error

  Function applied to incorrect argument.
    expects: _ * {b: [bool], ...}
    but got: _ * {b: [int], ...}
    in: := (mono, {a = 1, b = 0, c = "1"})

which makes the problem rather clear.

-Vesa Karvonen

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV