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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9B96ABB84 for ; Fri, 14 Jul 2006 18:39:39 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6EGdcC4013580 for ; Fri, 14 Jul 2006 18:39:38 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA27891 for ; Fri, 14 Jul 2006 18:39:38 +0200 (MET DST) Received: from sigma957.cis.mcmaster.ca (sigma957.CIS.McMaster.CA [130.113.64.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6EGda0D013570 for ; Fri, 14 Jul 2006 18:39:37 +0200 Received: from Gorash7.UTS.McMaster.CA (Gorash7.UTS.McMaster.CA [130.113.196.61]) by sigma957.cis.mcmaster.ca (8.13.4/8.13.4) with ESMTP id k6EGdO7e023009; Fri, 14 Jul 2006 12:39:24 -0400 (EDT) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by Gorash7.UTS.McMaster.CA (8.13.6/8.13.6) with ESMTP id k6EGdIMF008117; Fri, 14 Jul 2006 12:39:18 -0400 Received: from [69.193.76.85] (account carette@univmail.cis.mcmaster.ca HELO [192.168.1.101]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 132233484; Fri, 14 Jul 2006 12:39:18 -0400 Message-ID: <44B7C932.8020501@mcmaster.ca> Date: Fri, 14 Jul 2006 12:41:22 -0400 From: Jacques Carette Organization: McMaster University User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Pietro Abate , caml-list@inria.fr Subject: Re: [Caml-list] Re: (continuation monad) type problem... References: <20060712084056.EC61DAC97@Adric.metnet.fnmoc.navy.mil> <20060713070848.GA3885@pulp.rsise.anu.edu.au> In-Reply-To: <20060713070848.GA3885@pulp.rsise.anu.edu.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version-Mac: 4.7.1.128075, Antispam-Engine: 2.4.0.264935, Antispam-Data: 2006.7.14.83432 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' X-Miltered: at concorde with ID 44B7C8CA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44B7C8C9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; struct:01 ocaml:01 val:01 polymorphic:01 caml-list:01 jacques:01 jacques:01 defined:02 parameter:02 parameters:02 mcmaster:02 seems:03 module:03 unit:03 unit: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 It seems that a small modification to the definition of ContT can restore polymophism: module ContT (M : Monad) = struct type res = unit type ('a,'b) k = Cont of (('a -> 'b m) -> 'b m) and 'a m = (res * ('a,res) k M.m) M.m let return a = Cont (fun c -> c a) let bind m k = Cont (fun c -> let (Cont m') = m in m' (fun a -> let (Cont ka') = k a in ka' c)) end;; The main change is that to have 2 type parameters in your continuation. Also note that while 'a m is defined in terms of res (ie unit) for its second parameter, we know this doesn't matter (since continuations never really "return"), and thus ocaml is able to infer a polymorphic type for bind: val bind : ('a, 'b) k -> ('a -> ('c, 'b) k) -> ('c, 'b) k Jacques