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 17FE4BB84 for ; Wed, 12 Jul 2006 04:12:18 +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 k6C2CHCQ030851 for ; Wed, 12 Jul 2006 04:12:17 +0200 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 EAA22555 for ; Wed, 12 Jul 2006 04:12:16 +0200 (MET DST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6C2CCtH030706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 Jul 2006 04:12:15 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 393E954149 for ; Wed, 12 Jul 2006 12:12:09 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00996-10 for ; Wed, 12 Jul 2006 12:12:09 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 1882D54144 for ; Wed, 12 Jul 2006 12:12:06 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id 740BAA0AFCA; Wed, 12 Jul 2006 12:12:09 +1000 (EST) Date: Wed, 12 Jul 2006 12:12:09 +1000 From: Pietro Abate To: ocaml ml Subject: type problem... Message-ID: <20060712021209.GA21404@pulp.rsise.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at concorde with ID 44B45A81.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44B45A7C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 struct:01 flatten:01 sig:01 val:01 val:01 struct:01 ocamlc:01 -rectypes:01 wadler:01 anu:01 blog:98 blog:98 compile:01 compile:01 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 Hi all, I'm trying to type-check the continuation monad defined as follows: module LM = struct type 'a m = 'a list let return x = [x] let mzero = [] let bind m f = List.flatten (List.map f m) let mplus = List.append let guard b = if b then return () else mzero end ;; module CM : sig type r type 'node k = (('node -> 'node m) -> 'node m) and 'node m = (r * 'node k LM.m) LM.m val return : 'a -> 'a k val bind : 'a k -> ('a -> 'b k) -> 'b k val callCC : (('a -> 'b k) -> 'a k) -> 'a k end = struct type r type 'node k = (('node -> 'node m) -> 'node m) and 'node m = (r * 'node k LM.m) LM.m let return a = (fun k -> k a) let bind m f = (fun k -> m (fun x -> f x k)) let callCC f k1 = ( f (fun x k2 -> k1 x) k1 ) end if you compile it with ocamlc -rectypes -i ex.ml the compile says: Values do not match: val bind : (('a -> 'b) -> 'c) -> ('a -> 'd -> 'b) -> 'd -> 'c is not included in val bind : 'a k -> ('a -> 'b k) -> 'b k but at first sight, these two types should match ... maybe not ... or at least they do match if the type k is not cyclic... I think the solution is in Wadler paper http://portal.acm.org/citation.cfm?id=143169 in section 3.3, but it is not entirely clear what I should do here ... to get the right type... -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html