Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] What does underscore mean in this type expression?

35 views
Skip to first unread message

Richard Jones

unread,
Aug 30, 2008, 7:27:29 AM8/30/08
to caml...@inria.fr
I'm seeing this type error. Notice the difference is a lowly
underscore character.

The implementation libvirt.ml does not match the interface libvirt.cmi:
Values do not match:
val get_domains :
(_[> `R ] as 'a) Connect.t ->
?want_info:bool ->
Domain.list_flag list -> 'a Domain.t list * Domain.info list
is not included in
val get_domains :
([> `R ] as 'a) Connect.t ->
?want_info:bool ->
Domain.list_flag list -> 'a Domain.t list * Domain.info list

This syntax doesn't appear to be documented in the manual (unless it's
related to '_a). What does it mean?

I can supply some reproducer code if needed, but the code is rather
long at the moment.

Rich.

--
Richard Jones
Red Hat

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Christophe TROESTLER

unread,
Aug 30, 2008, 7:38:46 AM8/30/08
to Richard Jones, OCaml Mailing List
On Sat, 30 Aug 2008 12:27:18 +0100, Richard Jones wrote:
>
> val get_domains :
> (_[> `R ] as 'a) Connect.t ->
> is not included in
> val get_domains :
> ([> `R ] as 'a) Connect.t ->
>
> This syntax doesn't appear to be documented in the manual (unless it's
> related to '_a). What does it mean?

It is a weak type as you guessed. To convince you of that, here is
some code:

# let x = ref `X;;
val x : _[> `X ] ref = {contents = `X}

Cheers,
C.

Christophe TROESTLER

unread,
Aug 30, 2008, 9:58:37 AM8/30/08
to ri...@annexia.org, caml...@inria.fr
On Sat, 30 Aug 2008 14:03:10 +0100, Richard Jones wrote:
>
> > # let x = ref `X;;
> > val x : _[> `X ] ref = {contents = `X}
>
> OK ... so how to get rid of the error? Even supplying a full type for
> get_domains in the implementation doesn't get rid of it.
>
> Here's the code if anyone wishes to try:
>
> http://www.annexia.org/tmp/libvirt.mli
> http://www.annexia.org/tmp/libvirt.ml
>
> $ ocamlc -c libvirt.mli
> $ ocamlc -c libvirt.ml

Here is the crux of your problem

let f = let a = ref 0 in fun (x : [> `R ]) -> x;;

If you hoist [let have_list_all_domains = ref None] outside [let
get_domains], then it works fine. The type checker could certainly be
slightly improved [1] there but I do not know how difficult it is.

C.

---
[1] And maybe also the compiler: a rough check seem to indicate that
hiding the variable in the definition of f is slightly slower.

0 new messages