caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] What about polymorphic methods?
@ 2002-05-25  3:45 Alessandro Baretta
  2002-05-25  3:55 ` Jacques Garrigue
  0 siblings, 1 reply; 17+ messages in thread
From: Alessandro Baretta @ 2002-05-25  3:45 UTC (permalink / raw)
  To: Ocaml

I am writing a very simple class to handle bidirectional 
(bidi) lists in an object-functional manner. I have come up 
with a curious problem. The following text is the toplevel's 
output when it is passed my code.

#
type 'a bidi = Elem of 'a bidi * 'a * 'a bidi | Null
class ['a, 'b, 'c] bidi_list :
   'a list ->
   object
     method head : 'a bidi
     method left_iter : ('a -> 'b) -> 'b list
     method right_iter : ('a -> 'c) -> 'c list
     method tail : 'a bidi
     val first : 'a bidi
     val last : 'a bidi
   end
#   new bidi_list [1;2;3;4;5];;
- : (int, '_a, '_b) bidi_list = <obj>


The basic idea is that I want to convert a value with type 
'a list to a value belonging to class ['a] bidi_list. Now, 
if I leave 'b and 'c out of the parameter list my code 
refuses to compile, but even when I add 'b and 'c as type 
parameters, the type checker specializes them to '_b and 
'_c, which are not polymorphic.

Is there any way, then, to define polymorphic versions of 
the two iterators?

Alex Baretta

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-06-10 10:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-25  3:45 [Caml-list] What about polymorphic methods? Alessandro Baretta
2002-05-25  3:55 ` Jacques Garrigue
2002-05-25  5:42   ` John Prevost
2002-05-27 19:10   ` Alessandro Baretta
2002-05-27 18:22     ` John Max Skaller
2002-05-30  0:02       ` Alessandro Baretta
2002-05-27 18:27     ` [Caml-list] Possible use for camlp4 John Max Skaller
2002-05-27 18:35       ` Alexander V. Voinov
2002-05-27 19:33       ` Daniel de Rauglaudre
2002-05-29 19:25         ` John Max Skaller
2002-05-30  2:42           ` Jacques Garrigue
2002-05-30  8:15           ` Daniel de Rauglaudre
2002-05-27 19:37       ` Daniel de Rauglaudre
2002-06-02  8:34   ` [Caml-list] What about polymorphic methods? Lauri Alanko
2002-06-03 23:57     ` Jacques Garrigue
2002-06-08  9:52   ` [Caml-list] What about polymorphic methods Alessandro Baretta
2002-06-10 10:13     ` 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).