From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0EHkojk014815 for ; Fri, 14 Jan 2011 18:46:51 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAKYaME0+3JIE/2dsb2JhbACkVnO7KIVPBIsWgyI X-IronPort-AV: E=Sophos;i="4.60,323,1291590000"; d="scan'208";a="85122466" Received: from vs.philou.ch ([62.220.146.4]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Jan 2011 18:46:45 +0100 Received: from [192.168.1.120] (85-218-12-23.dclient.lsne.ch [85.218.12.23]) by vs.philou.ch (Postfix) with ESMTPSA id 5B0E61F2A7F3 for ; Fri, 14 Jan 2011 19:32:35 +0100 (CET) From: Philippe Strauss Content-Type: text/plain; charset=us-ascii Date: Fri, 14 Jan 2011 18:46:43 +0100 Message-Id: To: caml-list@inria.fr Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p0EHkojk014815 Subject: [Caml-list] writing a not too simple parametrized class interface Hello ocaml users, I'm in a fight with hindley-milner when writing a .mli for a set of classes which implement a pipeline pattern, for processing either float array or Complex.t array, caching the result in each pipeline element. each element type (class) inherit from node_virt_t, which use parametrized type for circumventing around the lack of "c++" like method overloading, for having the ability to use either float array or Complex.t array as input/output data type. the whole things works perfectly, but the .mli seems not easy to write. uncomment class node_spectrum_t or class node_mag_t and you'll get: File "nodes.mli", line 68, characters 30-45: Error: The type parameter Complex.t array does not meet its constraint: it should be float array which I don't understand. thanks for any advice. --8<-- nodes.mli : type node_parameters_t = Spectrum | Mag | Magn | Smooth | Fade | Eqmp | Power | Trim class type parameters_t = object val mutable len : int val mutable hlen : int val mutable sf : int val mutable chan : int val mutable f_half : float array val mutable f_log : float array val mutable fls : float val mutable fln : float val mutable fhn : float val mutable nth : float val mutable fll : float val mutable flh : float val mutable fhl : float val mutable fhh : float val mutable th_before : float val mutable th_after : float method set_len_sf : int -> int -> unit method get_len : int method get_hlen : int method get_sf : int method get_f_half : float array method get_f_log : float array method get_chan : int method set_chan : int -> unit method get_fln : float method set_fln : float -> unit method get_fhn : float method set_fhn : float -> unit method get_fls : float method set_fls : float -> unit method get_nth : float method set_nth : float -> unit method get_fade_freq : float * float * float * float method set_fade_freqs : float * float * float * float -> unit method get_th_before : float method set_th_before : float -> unit method get_th_after : float method set_th_after : float -> unit method get_parh : node_parameters_t -> string end class node_head_t : float array array -> object val impulses : float array array method get : int -> int * int * float array end class virtual ['b, 'c] node_virt_t : ('a, 'b) node_virt_t -> parameters_t -> int -> int -> object val previous : ('a, 'b) node_virt_t val parms : parameters_t val hres : (int * int * string, 'c) Hashtbl.t val mutable id : int array method get_id : int -> int method private inc_id : int -> unit method virtual ptyp : unit -> node_parameters_t method virtual process : 'b -> 'c method private pstore : int -> int * int * 'c method get : int -> int * int * 'c end (* class node_spectrum_t : node_head_t -> parameters_t -> int -> int -> object inherit [float array, Complex.t array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> Complex.t array end *) (* class node_mag_t : (Complex.t array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [Complex.t array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : Complex.t array -> float array end *) (* class node_magnormalize_t : (float array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [float array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> float array end *) (* class node_smooth_t : (float array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [float array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> float array end *) (* class node_fade_t : (float array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [float array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> float array end *) (* class node_eqminphase_t : (float array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [float array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> float array end *) (* class node_power_t : (float array, float array) node_virt_t -> parameters_t -> int -> int -> object inherit [float array, float array] node_virt_t method ptyp : unit -> node_parameters_t method process : float array -> float array end *) (* class node_trim_t : (float array, float array) node_virt_t -> (float array, float array) node_virt_t -> parameters_t -> object val nd_eqmp : (float array, float array) node_virt_t val nd_powm : (float array, float array) node_virt_t val parms : parameters_t method ptyp : unit -> node_parameters_t method make_coeffs : unit end *)