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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 419007EE25 for ; Fri, 8 Nov 2013 21:17:20 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of rossberg@mpi-sws.org) identity=pra; client-ip=139.19.1.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="rossberg@mpi-sws.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of rossberg@mpi-sws.org designates 139.19.1.49 as permitted sender) identity=mailfrom; client-ip=139.19.1.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="rossberg@mpi-sws.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@hera.mpi-klsb.mpg.de) identity=helo; client-ip=139.19.1.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="postmaster@hera.mpi-klsb.mpg.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0DABBGfVKLEwExhGdsb2JhbABZwyiBRw4BAQEKBwQJCRQogiUBAQUnEwYBATcBDwsOCi5XBhOIAQSqA4RSAQWOXAaPNDMHgyCBEK1E X-IPAS-Result: Al0DABBGfVKLEwExhGdsb2JhbABZwyiBRw4BAQEKBwQJCRQogiUBAQUnEwYBATcBDwsOCi5XBhOIAQSqA4RSAQWOXAaPNDMHgyCBEK1E X-IronPort-AV: E=Sophos;i="4.93,662,1378850400"; d="scan'208";a="41819533" Received: from infao0809.mpi-klsb.mpg.de (HELO hera.mpi-klsb.mpg.de) ([139.19.1.49]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 08 Nov 2013 21:17:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mpi-sws.org; s=mail200803; h=To:References:Message-Id:Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Content-Type:Mime-Version:Subject; bh=YmbvR02tyEHXtAwDYlff+aMje/1hll0bqcx+72XZFd0=; b=StDfWJ+u9o+q6HJAvgUa1Yev2CT5ZtvL0ao1Wp7hVN5ifWqIR5uGh8jIfcgVmKNgjcnSyuw/w83es/SQZ6hx8+EWiImH+2cteuck/NcX5IjLrarOjGAZKBW+SDUr0p5yzEVyDKwHgyLRPdzsCoApZ4YgVsA9CxEBKMUX2iG8RaE=; Received: from zak.mpi-klsb.mpg.de ([139.19.1.29]:44216) by hera.mpi-klsb.mpg.de (envelope-from ) with esmtp (Exim 4.72) id 1VesUW-000165-M4; Fri, 08 Nov 2013 21:17:18 +0100 Received: from mnch-4d04f032.pool.mediaways.net ([77.4.240.50]:58971 helo=[192.168.178.44]) by zak.mpi-klsb.mpg.de (envelope-from ) with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) id 1VesUW-0003KV-8P; Fri, 08 Nov 2013 21:17:16 +0100 Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) Content-Type: text/plain; charset=us-ascii From: Andreas Rossberg In-Reply-To: <527D452E.90701@cs.mcgill.ca> Date: Fri, 8 Nov 2013 21:17:15 +0100 Cc: OCaML List Mailing Content-Transfer-Encoding: quoted-printable Message-Id: References: <527D452E.90701@cs.mcgill.ca> To: Brigitte Pientka X-Mailer: Apple Mail (2.1822) X-MPI-Local-Sender: true Subject: Re: [Caml-list] recursive records On Nov 8, 2013, at 21:10 , Brigitte Pientka wrote: > I am playing around with using recursive records to define observations a= bout > streams simulating essentially the ideas described in "Copatterns:Program= ming infinite structures by observations" presented at POPL'13. >=20 > type 'a susp =3D Susp of (unit -> 'a) >=20 > type 'a str =3D {hd: 'a ; tl : ('a str) susp} >=20 > let rec ones =3D {hd =3D 1 ; tl =3D Susp (fun () -> ones)} >=20 > This works fine and many examples can be elegantly written this way. How= ever, > when I define the stream ones via the function delay, OCaml fails. >=20 > let delay f =3D Susp f >=20 > let rec ones =3D {hd =3D 1 ; tl =3D delay (fun () -> ones)};; > Characters 15-53: > let rec ones =3D {hd =3D 1 ; tl =3D delay (fun () -> ones)};; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Error: This kind of expression is not allowed as right-hand side of `let = rec' >=20 > Could someone explain why this fails? Roughly speaking, let rec only allows syntactic values as right-hand sides = (to ease implementation and to avoid issues with potential observable side = effects during tying of the recursive knot). An application like the one of= delay is not a value. If you replace it by a direct application of the Sus= p constructor it should work. /Andreas