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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2E03FBB81 for ; Fri, 11 Nov 2005 06:42:51 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAB5go5C002155 for ; Fri, 11 Nov 2005 06:42:50 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA11179 for ; Fri, 11 Nov 2005 06:42:50 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAB5gmmv002152 for ; Fri, 11 Nov 2005 06:42:49 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id jAB5glb5008157; Fri, 11 Nov 2005 14:42:47 +0900 (JST) Date: Fri, 11 Nov 2005 14:42:47 +0900 (JST) Message-Id: <20051111.144247.68530040.keiko@kurims.kyoto-u.ac.jp> To: garrigue@math.nagoya-u.ac.jp Cc: caml-list@inria.fr Subject: Re: [Caml-list] private rows question From: Keiko Nakata In-Reply-To: <20051111.141222.106258050.garrigue@math.nagoya-u.ac.jp> References: <20051110.125000.68545682.keiko@kurims.kyoto-u.ac.jp> <20051111.141222.106258050.garrigue@math.nagoya-u.ac.jp> X-Mailer: Mew version 4.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43742F5A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43742F58.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 functor:01 typable:01 sig:01 val:01 struct:01 checker:01 reuse:01 int:01 int:01 jacques:01 garrigue:03 garrigue:03 module:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: Jacques Garrigue > From: Keiko Nakata > > > Why the following functor G is not typable? > > I thought that g could have a type something like int -> [< `A | `B ]. > > > > module G(X:sig type t = private [< `A ] val f : int -> t end) = struct > > let g x = if x = 0 then `B else X.f x > > end > > Since g may return `B, and probably `A (the probably concerns your > intention), the expected type would be > g : int -> [> `A | `B ] > Next, if you want f to have a private row type, then you should > disconnect its type from the type of g (otherwise the type of g must > be the same as f.) So I would expect something like: > let g x = if x = 0 then `B else (X.f x : [< `A] :> [> `A]) Thank you for the correction. Obviously, the type checker is much more brilliant than me :-) Private rows seem to give me more opportunities to reuse my program codes than I expected. Keiko NAKATA