From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA13916; Fri, 29 Aug 2003 13:54:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA19399 for ; Fri, 29 Aug 2003 13:54:47 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7TBslf04987 for ; Fri, 29 Aug 2003 13:54:47 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19shq2-0000F6-00 for ; Fri, 29 Aug 2003 12:54:46 +0100 Date: Fri, 29 Aug 2003 12:54:46 +0100 To: caml-list@inria.fr Subject: [Caml-list] Polymorphic graph widget problem Message-ID: <20030829115446.GA879@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; widget:01 widget:01 lablgtk:01 plots:01 gobj:01 generalise:01 gobj:01 int':01 freshmeat:01 ltd:98 bool:01 bool:01 ints:01 irrelevant:01 gtk:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk As part of a project I'm doing at the moment, I've written a Gtk graph widget using lablgtk. The graph currently plots ints, so the type looks something like this: class chart : ?width:int -> ?height:int -> ?packing:(GObj.widget -> unit) -> ?show:bool -> int array -> (* the data being plotted *) object method repaint : Gdk.Rectangle.t option -> unit end All fine, but now I'd like to generalise this so it can plot floating point values as well as int, thus: class ['a] chart : ?width:int -> ?height:int -> ?packing:(GObj.widget -> unit) -> ?show:bool -> 'a array -> (* the data being plotted *) object method repaint : Gdk.Rectangle.t option -> unit end The problem with this is that at various places in the implementation we need to break the polymorphism. eg. To plot Y labels we call 'string_of_int', and to work out the height of the Y axis we do some sums on the values using the (+) operator. What I need is some way to isolate the parts which break the polymorphism. How do I do that? Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. All new technology is irrelevant until it is taken up by the public. ------------------- 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