From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E4BE9BC6B for ; Sat, 4 Aug 2007 18:03:19 +0200 (CEST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.190]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l74G3J0x001458 for ; Sat, 4 Aug 2007 18:03:19 +0200 Received: by fk-out-0910.google.com with SMTP id z22so1121732fkz for ; Sat, 04 Aug 2007 09:03:19 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding:sender; b=U30WrEkAZyqdJUGxRBG64jzphx4eYWQu6d43hEeS3Cqlx3oLFI0zVnM/pSLgYsPELE0mI19dPWJm12slflye4nhid5/ekMb43F5gzLGbSMuNCQXIoh3mRqpEot6zfWrbuW06/9M/QthZn2oe1HIxitqIyd8h9Ze/8IR0KjLj7sA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding:sender; b=H9+srbGP6zPvwNvY5H7BukUiBd7fcYPFe8UL1Vxse+r59t9IY4AAB69y04wJk0CbHRlbq/gvZdTtuzH89o6dvbYvlds+yiTNR/2iN0OCBDXveuAAT9WwmPiAKnXIf/VwQc3gVcAy8azcoDf5OqFLH+YfI2qDlT0wBgl2J3u9wEY= Received: by 10.86.58.3 with SMTP id g3mr3058353fga.1186243399238; Sat, 04 Aug 2007 09:03:19 -0700 (PDT) Received: from ?192.168.0.2? ( [87.88.165.197]) by mx.google.com with ESMTPS id e8sm13709042muf.2007.08.04.09.03.17 (version=SSLv3 cipher=RC4-MD5); Sat, 04 Aug 2007 09:03:18 -0700 (PDT) Message-ID: <46B4A343.5030900@lix.polytechnique.fr> Date: Sat, 04 Aug 2007 18:03:15 +0200 From: Arnaud Spiwack User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Caml List Subject: Instanciating functor types with extra parameters Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Arnaud Spiwack X-j-chkmail-Score: MSGID : 46B4A347.000 on concorde : j-chkmail score : XX : 5/20 0 0.000 -> 2 X-Miltered: at concorde with ID 46B4A347.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lix:01 functor:01 functor:01 orderedtype:01 sig:01 val:01 orderedtype:01 struct:01 ocaml:01 genericity:01 occurences:01 functors:01 syntax:01 encapsulated:01 innocent:98 Hi caml list ! The recent, or rather current, thread on priority queues, raised back an issue that've I've been really infuriated with a couple of time the past, like, 2 years. When I have a functor type, like for example (not too innocent I'm afraid) : module type OrderedType = sig type t val compare : t -> t -> int end Something that naive intuition would allow you to do is something like : module GenOrder : OrderedType = struct type t = 'a let compare = compare end Though this is more or less nonsense. And is not currently possible under OCaml type system. My point is that I know absolutely no way of doing such a thing. Hence I can't make a set with total or partial genericity. If I want to add type parameters I have to rewrite the *whole* set library. Actually... I've got to copy past it, and replace all occurences of t with an 'a t for instance. Or ('a,'b) t if I have two arguments. I really had to do that once, and almost a couple of other time. That's why it infuriates me as I said earlier. The whole issue is that it totaly breaks the purpose of functors to have to recast it for a very small type variation. Thus I'm raising the question : is there a good reason (I mean a good reason from the user point of view here, I kinda understand it may make things much more complicated). An other question would be : is there a way to work around this issue ? Yet another question would be : should there be a separated syntax to mean that the type can have arbitrary arguments encapsulated ? PS : I'm aware that there is (several) available implementation of unfunctorized Set and Map, the questions are about the more general case though. I very often give up the idea of writing something in a functorized style, because it's too fragile, which is a bit paradoxal to me. Arnaud Spiwack