caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Polymorphic method and polymorphic type
@ 2008-03-17 10:21 SerP
  2008-03-17 12:26 ` [Caml-list] " SerP
  2008-03-17 12:37 ` Jacques Garrigue
  0 siblings, 2 replies; 4+ messages in thread
From: SerP @ 2008-03-17 10:21 UTC (permalink / raw)
  To: Caml-list, caml-list-bounces

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?


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

end of thread, other threads:[~2008-03-17 12:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-17 10:21 Polymorphic method and polymorphic type SerP
2008-03-17 12:26 ` [Caml-list] " SerP
2008-03-17 12:51   ` Jacques Garrigue
2008-03-17 12:37 ` 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).