From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 304347ED1A for ; Thu, 17 May 2012 16:52:35 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskDAPsPtU/ZSMDjlGdsb2JhbABEs0AiAQEBAQkLCQkUAySCFQEBBAEnCwFGBQsLISUPAQQoIROHfwEJCbFhH4oLkGoDm1yNSQ X-IronPort-AV: E=Sophos;i="4.75,610,1330902000"; d="scan'208";a="158801527" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 May 2012 16:52:34 +0200 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate02.web.de (Postfix) with ESMTP id 6C6E31C4B94AA for ; Thu, 17 May 2012 16:52:34 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb002) with ESMTPA (Nemesis) id 0LfiZ8-1RlY9w0Ll4-00pK92; Thu, 17 May 2012 16:52:34 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SV249-00076v-EG; Thu, 17 May 2012 16:52:33 +0200 From: Goswin von Brederlow To: Arnaud Spiwack Cc: OCaML Mailing List References: Date: Thu, 17 May 2012 16:52:33 +0200 In-Reply-To: (Arnaud Spiwack's message of "Fri, 11 May 2012 12:03:32 +0200") Message-ID: <87ehqi97wu.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:Q7o4yKeaqPvFbTIorLdN8y/uxfqBqd3fc+Vdcl00gO7 w3NF2UjJVMHpIMIJfsrybJIf9dMJNgoYtUfNOY9XrYgMe+V7ma N20r4Q8CYIU8cFb78cPrI+kf6PWodWoiD958Dee9w57YldS9yk P7lt0bDXugZVZKgzIB8jbO/XR92HZSKdxHJYBe1fTlZkTVrhdx YttLFZYLuE31H0j3f575Q== Subject: Re: [Caml-list] One-value functors Arnaud Spiwack writes: > Dear all, > > With the advent of first-class modules, I find myself more and more wanting to > write functors with only one (value) component, just to benefit from type > dependencies. Here is an example (randomly) extracted from Oleg Kiselyov and > Jeremy Yallop: > > > type a and b > module type TC = sig type 'a t end > module type Subst = functor (A:TC) -> sig val x : a A.t -> b A.t end What are you trying to do there? Why do you need a functor for that at all? TC just having a type doesn't make sense to me. > If this pattern had to become widespread, it would be worth agreeing for a name > on the single component, though it's a bit unnecessary to need a name at all. > It get very verbose, though, when trying to applying the functor. Supposing I > have a module Subst:Subst : > > > let module S = Subst(sig type 'a t = 'a list) in > S.x ? So S.x would be a function that turns for example an int list into a float list, e.g. let x list = List.map float_of_int list? How would you write Subst that it takes anything but 'a list (and Obj.magic doesn't count)? How would the functor look like that would accept 'a list or 'a array as argument? Seems to me TC needs to also contain the map function for this to work. And then why not just use (List.map float_of_int) as closure? > I believe this would be something cool to have, so I came with two questions: > 1/ Is there some demand for this kind of things (if not, I'm not sure it's > worth pursuing, though of course demand could appear after supply) > 2/ I don't see how to define the type syntax in camlp4, because of the inlining > thing, could it be done? >    (an alternative may be to have (X:A) => t be a module type, but then  (X:A) > => (Y:B) => t is not a valid type, so we would need syntaxes for n-ary > abstraction/applications) Hard to say if I can't even understand what "this kind of thing" is. MfG Goswin