caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: SerP <serp@stork.ru>
To: Caml-list@yquem.inria.fr,
	caml-list-bounces <caml-list-bounces@yquem.inria.fr>
Subject: Polymorphic method and polymorphic type
Date: Mon, 17 Mar 2008 13:21:41 +0300	[thread overview]
Message-ID: <47DE4635.7050101@stork.ru> (raw)

Simple example. All functions are fake.

class getter = object method add_some p = p+1 end;;
type 'a get_mode = [ `Read | `Watch of (#getter as 'a)];;
let string_of_get_mode (gm: 'a get_mode) = match gm with `Read -> "Read" 
| `Watch g -> let i = g#add_some 1 in ("Watch "^ (string_of_int i));;
class c = object method pgm : 'a. ('a get_mode) -> string = 
string_of_get_mode end;;
--------------
This expression has type 'a. (#getter as 'a) get_mode -> string
but is here used with type 'b. (#getter as 'b) get_mode -> string
Type #getter as 'c = < add_some : int -> int; .. >
is not compatible with type 'c

====================
Please help. Is it my error? how should we do that the right way?


             reply	other threads:[~2008-03-17 10:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 10:21 SerP [this message]
2008-03-17 12:26 ` [Caml-list] " SerP
2008-03-17 12:51   ` Jacques Garrigue
2008-03-17 12:37 ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47DE4635.7050101@stork.ru \
    --to=serp@stork.ru \
    --cc=Caml-list@yquem.inria.fr \
    --cc=caml-list-bounces@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).