From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 91355BBAF for ; Mon, 16 Nov 2009 08:34:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtgPAACPAEtV2gB4h2dsb2JhbACEcpRBgmsBAQEKCwgHFagijw6BMII4VASIPg X-IronPort-AV: E=Sophos;i="4.44,750,1249250400"; d="scan'208";a="50390742" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail4-smtp-sop.national.inria.fr with SMTP; 16 Nov 2009 08:34:09 +0100 Received: from [192.168.0.10] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id 65EA212C0FD; Mon, 16 Nov 2009 08:34:08 +0100 (CET) Message-ID: <4B010073.6090402@citycable.ch> Date: Mon, 16 Nov 2009 08:34:11 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Polymorphic functors / modules and OCaml-R Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; guillaume:01 guillaume:01 functors:01 sig:01 sig:01 polymorphism:01 functors:01 bindings:01 struct:01 struct:01 polymorphic:01 polymorphic:01 abstract:01 unsafe:01 tuple:02 Hello. I've been trying stuff like these: > # module type 'a A = sig > Error: Parse error: [a_UIDENT] expected after "type" (in [str_item]) > # module type ['a] A = sig > Error: Parse error: [a_UIDENT] expected after "type" (in [str_item]) > # module type A = sig module type B end > ;; > Error: Failure: "abstract/nil module type not allowed here" > # Is there a way, somehow, of introducing such polymorphism in modules / functors? That would help me a lot. I'm currently try to write bindings for R code, with OCaml-R, and I can come up with stuff like this: > module Description : R.LibraryDescription = struct > let name = "xts" > let symbols = ["xts"] > end > > module Library : R.Library = OCamlR.Require (Description) > > let [xts] = Library.root What would be nice would be Description to be polymorphic in some sense or another, so that I could describe the various R symbols that are made available by the xts library. The other, rather unrelated solution I see would be to replace stuff above by something like: > module Description : R.LibraryDescription = struct > let name = "xts" > let symbols = ["xts"; "print_xts"] > end > module Library : R.Library = OCamlR.Require (Description) > > type t > external list_to_tuple : 'a list -> 'b = "list_to_tuple" > let ( (xts : unit -> t), > (print_xts : t -> unit) > ) = list_to_tuple Library.root where list_to_tuple would be a function constructing the tuple (no fixed size) representing a given list. This is rather unsafe... A polymorphic module, with argument a module type, would be something very useful to describe a R library... All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/