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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id D4605BC57 for ; Mon, 26 Apr 2010 18:54:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtsAAIli1UuLEwExkWdsb2JhbACcUQEBAQEJCwoHEQUdtBEBjmAFhQs X-IronPort-AV: E=Sophos;i="4.52,274,1270418400"; d="scan'208";a="49673683" Received: from infao0809.mpi-sb.mpg.de (HELO hera.mpi-sb.mpg.de) ([139.19.1.49]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 26 Apr 2010 18:54:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mpi-sb.mpg.de; s=mail200803; h=Message-ID:In-Reply-To: References:Date:Subject:From:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=cJ0i7HIpj83Q09paL432dx/cMSNVuGKjX7 QzlFgBRHg=; b=M2urYtZgR+fsLRofTdxWESHKsAbRLdRUMUhUUN6hK28Ghhukdl DNK69ZzP08eJCwgowjgWEt5/0PS4CyAvfE8rpRkLMagz4ImauuhgBydAVsZVZKdJ VpnCPEPXOfUBOwo0Ev+5syw5HLgfx9mtpVu9BwAMjKZN81P32H0VZrkuI= Received: from maniac.mpi-sb.mpg.de ([139.19.1.26]:32946) by hera.mpi-sb.mpg.de (envelope-from ) with esmtp (Exim 4.69) id 1O6Ra3-0004Sy-UJ; Mon, 26 Apr 2010 18:54:50 +0200 Received: from www-data by maniac.mpi-sb.mpg.de with local (Exim 4.69) (envelope-from ) id 1O6Ra3-000469-JS; Mon, 26 Apr 2010 18:54:47 +0200 Received: from 80.146.185.83 (SquirrelMail authenticated user rossberg) by mail.mpi-sws.org with HTTP; Mon, 26 Apr 2010 18:54:47 +0200 (CEST) Message-ID: <5ac779c6dcc89fe009150414e374043c.squirrel@mail.mpi-sws.org> In-Reply-To: <4BD5C057.7020800@wp.pl> References: <4BD229E4.4050003@wp.pl> <4BD5C057.7020800@wp.pl> Date: Mon, 26 Apr 2010 18:54:47 +0200 (CEST) Subject: Re: [Caml-list] Re: Module type of a structure returned by functor From: rossberg@mpi-sws.org To: "Dawid Toton" Cc: "caml-list" User-Agent: SquirrelMail/1.4.15 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Spam: no; 0.00; functor:01 rossberg:01 foo:01 functor:01 sig:01 val:01 foo:01 functors:01 ocaml:01 struct:01 sig:01 val:01 wrote:01 signatures:01 signatures:01 Dawid Toton wrote: > I've found that I have more fundamental problem. What is the exact > meaning of the following line? > > module type Foo = functor (X:X) -> sig val foo : X.t end > > (1) Foo is not a functor, but it is a type of some functors that map > modules to modules > (2) Foo is a mapping from modules to module types > > Currently I think that it (1) is true and (2) is false. Let me know if > I'm wrong. That's right. A construct for (2), sometimes referred to as "parameterized signatures", does not exist in OCaml directly. However, you can encode it using a functor with a nested signature in its result: module FooOf (X : X) = struct module type S = sig val foo : X.t end end Now, for example: module F (X : X) (Y : FooOf(X).S) = ... > It means that there is no easy way to get module type of what results > from functor application. I think that the solution is to separately > define signature of results of the functor and use "with type" clauses > to recreate all result module types that are needed. > > This is not very bad, but I'm still wondering if "module type of..." of > 3.12 will provide elegant solution for this. Interesting, it looks like it may. I wasn't aware that singleton signatures will be coming in 3.12 - nice. /Andreas