caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] type inference with classes
@ 2012-08-03  4:23 Ivan
  2012-08-03  4:50 ` Alain Frisch
  0 siblings, 1 reply; 6+ messages in thread
From: Ivan @ 2012-08-03  4:23 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

Hi!

I've mentioned that in some cases ocaml can't infer type (or maybe it can,
but didn't want to...) of some objects.
Right to this moment, I've just do as ocaml wants - annotate a type and
move forward. But now I want to make things more consciously. The reason is
simple - sometimes ocaml infers types correctly and denotes a type error in
my code, but I, mistakenly thinking that it can't infer type of object,
loose my time in useless type annotating of different identifiers. Or vice
versa, the code is correct, except for some undecidable object type, and I
spend h^Wminutes in checking my code for errors.

So, I'would like to know the rules of type inference failures with object
types. In what cases an object type can and must be inferred, and in what
it must be annotated explicitly?

Can someone share this arcane knowledge or, at least, point me at some
sources, explaining this issue?

Thanks everybody in advance!

[-- Attachment #2: Type: text/html, Size: 1072 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: [Caml-list] type inference with classes
@ 2012-08-03 23:14 Jacques Garrigue
  0 siblings, 0 replies; 6+ messages in thread
From: Jacques Garrigue @ 2012-08-03 23:14 UTC (permalink / raw)
  To: Ivan, Garrigue Jacques; +Cc: Mailing, OCaML

From: Ivan <ivg@ieee.org>
>>The fact is that, at least in lablgtk-2.14.2 (the current version), the
>> type is
>>
>>       expand_row : ?all:bool -> Gtk.tree_path -> unit

>The first thing I've tried was specifying explicitly argument ~all. But
>compiler refused to accept this too, with exactly the same error message...

For the ~all argument to be properly processed, you first need the
type of the method to be known.
The best solution is to put a type annotation on v.
The next solution is to pass an explicit optional argument:

	v#expand_row ?all:None x

I don't like it much because parameter order matters.

Jacques

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-03 23:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03  4:23 [Caml-list] type inference with classes Ivan
2012-08-03  4:50 ` Alain Frisch
2012-08-03  5:15   ` Ivan
2012-08-03  5:32     ` Jacques Garrigue
2012-08-03  6:09       ` Ivan
2012-08-03 23:14 Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).