caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Recursive Parametric class type Typing
@ 2011-03-19 15:48 Raphael Proust
  2011-03-19 17:48 ` Guillaume Yziquel
  2011-03-19 20:02 ` Philippe Strauss
  0 siblings, 2 replies; 6+ messages in thread
From: Raphael Proust @ 2011-03-19 15:48 UTC (permalink / raw)
  To: caml-list

Hi list,

Trying to bind a javascript library for js_of_ocaml, I encountered the following
pattern (here drastically simplified):

class type ['t] c =
  object
    method plus: 't -> unit
    method minus: unit -> 't
    method container: unit -> container
  end
and container =
  object
    method int: unit -> int c
    method string: unit -> string c
  end

The following error is raised at compile time:
Error: This type string should be an instance of type int

In the use case:
- instead of [int] and [string] there are six different [class type]s;
- [classe type]s have more methods; and
- there are additional recursive [class type]s


Why is there such a limitation on the types? Is there a work around that
wouldn't induce (too  much) code duplication?

Thanks,
-- 
______________
Raphaël Proust


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

end of thread, other threads:[~2011-03-19 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-19 15:48 [Caml-list] Recursive Parametric class type Typing Raphael Proust
2011-03-19 17:48 ` Guillaume Yziquel
2011-03-19 19:20   ` Raphael Proust
2011-03-19 19:45     ` Guillaume Yziquel
2011-03-19 20:36       ` Raphael Proust
2011-03-19 20:02 ` Philippe Strauss

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).