Anyone who has programmed in OCaml for any length of time knows the pain that comes from accidentally using types incorrectly in lists. Since OCaml is (1) statically typed and (2) determines types at compile-time, you have to be consistent when you're using a particular value. That is, if you have something that's a type (i.e., a record) with {time : float; value : float}. You can't start using that same record as a tuple (float * float) or else you get an error. That makes sense. What often doesn't make sense is that OCaml chooses to tell you that you're using some value incorrectly in the strangest of places--not where you're using it incorrectly, but where it's determined the type.
So if you use the value in some function in one location incorrectly, it might tell you that you're using it incorrectly. However under many common circumstances it will tell you that the problem exists in the call to the function rather than in the function itself. That can get very frustrating when debugging compile-time errors.
Recent Comments