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 DFC287F75C for ; Sun, 24 Aug 2014 17:33:46 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of lpw25@cam.ac.uk) identity=pra; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@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@cam.ac.uk) identity=mailfrom; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="lpw25@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-50.csi.cam.ac.uk) identity=helo; client-ip=131.111.8.150; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="lpw25@cam.ac.uk"; x-sender="postmaster@ppsw-50.csi.cam.ac.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlkGANQE+lODbwiWf2dsb2JhbABZs1QGpG4BgQgWEAEBCwsKCBQphAQBBAEnUgULCyElDwEESYhNCAS9KYRLF4V8iGhoB4RMBZxJmGuDOgEBAQ X-IPAS-Result: AlkGANQE+lODbwiWf2dsb2JhbABZs1QGpG4BgQgWEAEBCwsKCBQphAQBBAEnUgULCyElDwEESYhNCAS9KYRLF4V8iGhoB4RMBZxJmGuDOgEBAQ X-IronPort-AV: E=Sophos;i="5.04,390,1406584800"; d="scan'208";a="76383993" Received: from ppsw-50.csi.cam.ac.uk ([131.111.8.150]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Aug 2014 17:33:46 +0200 X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from host86-144-7-20.range86-144.btcentralplus.com ([86.144.7.20]:38016 helo=study.localdomain) by ppsw-50.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:lpw25) (TLSv1.2:AES128-GCM-SHA256:128) id 1XLZnc-0001Ch-sk (Exim 4.82_3-c0e5623) (return-path ); Sun, 24 Aug 2014 16:33:45 +0100 From: Leo White To: Christoph =?utf-8?Q?H=C3=B6ger?= Cc: caml users References: <53F49BAE.40901@tu-berlin.de> X-Face: "XWxb[u_Z\PA_Y?9@|IA!!+jTb(/290-*ea/Un$I0B98.$n%eL.;2w*,z]WR#T:,p[ NBd++M7l]#7zj7!{~iw $W-"/=|dVjhT[D{4~gE}gK<2`.6fs!;uqqud]vs2N/3^m7{aS1V, Date: Sun, 24 Aug 2014 16:48:33 +0100 In-Reply-To: <53F49BAE.40901@tu-berlin.de> ("Christoph \=\?utf-8\?Q\?H\=C3\=B6ge\?\= \=\?utf-8\?Q\?r\=22's\?\= message of "Wed, 20 Aug 2014 14:59:26 +0200") Message-ID: <87k35x6g8e.fsf@study.localdomain> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Caml-list] recursive values of abstract types, aka Batteries ParserCo > I wanted to parse a small lambda-calculus in OCaml and had batteries > already as a dependency. Batteries comes with ParserCo, a small parser > combinator library. Since I did not want to complicate things further, > I decided to stick with it and avoid any parser generator. Using a > monadic combinator library for a scannerless parser should be a > relatively simple exercise, right? > > Unfortunately, it seems that ParserCo only exposes an abstract type: > > type ('a, 'b, 'c) t > > which is, of course, a function: > > type ('a, 'b, 'c) t = ('a, 'c) Source.t -> ('a, 'b, 'c) result > > This prevents me from defining any recursive parsers, since OCaml > won't let me let-rec a value of an abstract function type. I cannot do > eta-expansion, because the type is abstract, and I also do not have a > type constructor at hand. > > How does one handle such cases in OCaml? Does this really mean, you > cannot have recursive values of abstract function types? Hi Christoph, I haven't used ParserCo (or even looked at the documentation), but the 'lazy' keyword has a relaxed notion of what can be defined recursively, so creating a recusive `('a, 'b, 'c) t Lazy.t` and then forcing it may well solve your problem. Regards, Leo