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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 89BF17EE49 for ; Fri, 22 Feb 2013 19:33:46 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@hermes.cam.ac.uk) identity=pra; client-ip=131.111.8.151; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@hermes.cam.ac.uk"; x-sender="lpw25@hermes.cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@hermes.cam.ac.uk) identity=mailfrom; client-ip=131.111.8.151; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@hermes.cam.ac.uk"; x-sender="lpw25@hermes.cam.ac.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@ppsw-51.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.151; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@hermes.cam.ac.uk"; x-sender="postmaster@ppsw-51.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8AALO5J1GDbwiXmWdsb2JhbABEwjEWDgEBAQEBCAsLBxQngiABBScRQRABCkZXBogltkOJApJVA5dXhFeJI4RT X-IPAS-Result: Av8AALO5J1GDbwiXmWdsb2JhbABEwjEWDgEBAQEBCAsLBxQngiABBScRQRABCkZXBogltkOJApJVA5dXhFeJI4RT X-IronPort-AV: E=Sophos;i="4.84,717,1355094000"; d="scan'208";a="3170513" Received: from ppsw-51.csi.cam.ac.uk ([131.111.8.151]) by mail3-smtp-sop.national.inria.fr with ESMTP; 22 Feb 2013 19:33:33 +0100 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.ucs.cam.ac.uk/email/scanner/ Received: from hermes-1.csi.cam.ac.uk ([131.111.8.51]:43146) by ppsw-51.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:25) with esmtpa (EXTERNAL:lpw25) id 1U8xR7-0007yF-XL (Exim 4.72) (return-path ); Fri, 22 Feb 2013 18:33:33 +0000 Received: from prayer by hermes-1.csi.cam.ac.uk (hermes.cam.ac.uk) with local (PRAYER:lpw25) id 1U8xR7-0007pN-A8 (Exim 4.72) (return-path ); Fri, 22 Feb 2013 18:33:33 +0000 Received: from [128.232.64.15] by webmail.hermes.cam.ac.uk with HTTP (Prayer-1.3.5); 22 Feb 2013 18:33:33 +0000 Date: 22 Feb 2013 18:33:33 +0000 From: Leo White To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: OCaml Message-ID: In-Reply-To: <5127AFD7.5040002@gmail.com> References: <5127AFD7.5040002@gmail.com> X-Mailer: Prayer v1.3.5 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 Sender: "L.P. White" Subject: Re: [Caml-list] strange typechecking result On Feb 22 2013, Matej Kosik wrote: >Hello, > >For one of my modules, the typechecker started to raise strange >complaints. I was not able to figure out exactly why, but at least I >wanted to narrow down the problem. > >This small program: > > type r1 = {l1 : unit list} > > and r2 = {l2 : int64 list} > > let rec f1 _ = > () > > and _ r1 = > f1 r1.l1 > > and _ r2 = > f1 r2.l2 > >is rejected by the typechecker with a following error message: > > File "test.ml", line 12, characters 5-10: > Error: This expression has type int64 list > but an expression was expected of type unit list > >I do not understand why the given program was rejected. > I think that by default recursive uses of a function are monomorphic. You can fix this with an explicit polymorphic annotation: let rec f1: 'a. 'a -> unit = fun _ -> () and f2 r1 = f1 r1.l1 and f3 r2 = f1 r2.l2;; Regards, Leo