From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: Srfi-159/166 - monadic formatting for guile Date: Fri, 14 Jun 2019 11:38:04 +0200 Message-ID: References: <87pnnj7pd9.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="89861"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Cyrus-JMAP/3.1.6-663-gf46ad30-fmstable-20190607v1 Cc: guile-user@gnu.org To: "Mark H Weaver" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jun 14 11:50:57 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hbirG-000NAA-GZ for guile-user@m.gmane.org; Fri, 14 Jun 2019 11:50:55 +0200 Original-Received: from localhost ([::1]:49680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbirF-0007Wu-3B for guile-user@m.gmane.org; Fri, 14 Jun 2019 05:50:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40980) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbiel-00053R-Gd for guile-user@gnu.org; Fri, 14 Jun 2019 05:38:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbiej-0003Sj-KN for guile-user@gnu.org; Fri, 14 Jun 2019 05:37:59 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:41735) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbiej-0003Px-91 for guile-user@gnu.org; Fri, 14 Jun 2019 05:37:57 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B1F40221BC; Fri, 14 Jun 2019 05:37:53 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute1.internal (MEProxy); Fri, 14 Jun 2019 05:37:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type:content-transfer-encoding; s=fm3; bh=KH2FM 6itZ1n2vrmeK14VczXry7O3EOD4524FoJiAgSc=; b=tYVSvPXf3S2JxeJxhJ4Qd bKvomGGuAT4XKYLXra7IEifpjkWs4tIds/ifXULqXfz/3BSkKlixUoAsg4ObOwej 5c1GMT5FVnbTYY9dbaWC48nWmCYcevaF4PGyqDkHkR+rrTs0OiY9ie0a3Pm2gDxO 99Xnijv7F96dLC7HoUckpPcoNvl+m8LwuJ7FB0iHIiIKmFeA0ysjy/J8HsHRisqY TWz/Y7hP6qapqGZ6YEg6ruFEhBd02H/98Cpp3tAZ6i1QybU7TSkb2lEZLZueQrl9 nkcxiGc9t3RPe7q2g9+zSOkKjBigwFxjs8DPFsfbEA2pfgMagbgowRWGt4pKXR7E Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=KH2FM6itZ1n2vrmeK14VczXry7O3EOD4524FoJiAg Sc=; b=p9WowmdxbYXlNkrbBW7A+TgyAoj2yqc6q6ruuVVRHXW/LliEoY2F/G/d+ ol+rfM9dISb+xSkhPhgw/Qrzlh1IOPe6Fv9RfwNeA9toRGxN26kBbGskymxoutcR Mw9Jqg9UyA1K0+BWqSvYIpBbPV1tQ3uctwWBGmZIFgxz+QudHcqIjgXnXwNAEeU8 ZUYGVuh1SKzxVCiqxtscPdGHoH5LlinAq0c0EqJ+E4hgEWZ679qiCIOvoLc22ek+ 4PYmURoJ9P/DsLHeo0QfP+H1W2oi/ZHX1fCrMpd4ctzebH5zE0ra7baYFGHC5GvV UkFCcES21/eK181OP6b1WdsxLqr8g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeiuddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepnfhinhhushgpuehjnphrnhhsthgrmhcuoehlihhnuhhs rdhinhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvgeqnecuffhomhgrihhnpegsihhtsg hutghkvghtrdhorhhgpdhstghhvghmvghrshdrohhrghenucfrrghrrghmpehmrghilhhf rhhomheplhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrghilhdrshgvnecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 38E72C200A3; Fri, 14 Jun 2019 05:37:53 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <87pnnj7pd9.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15547 Archived-At: Hi Mark! I am not sure I understand what you mean, but i suspect it is already so= lved, since for simple cases show will use display/write. So unless you = try to do advanced formatting of circular lists it will do whatever disp= lay or write does. The same thing goes for custom printers. In fact, any= thing that isn't a regular procedure will be printed just as it does in = guile. Due to formatters being procedures, it is currently not possible = to distinguish between formatters and other lambdas, but wrapping a lamb= da in (written ...) works just as (write ...).=20 So unless you tell show to do something else, it will default do guile's= standard way.=20 (show #t (exact->inexact 1/7)) is the same as (display (exact->inexact 1= /7)), however (show #t (with ((precision 2)) ...)) is not. I don't know what circular structures guile uses internally, but (show..= .)ing a circular list without any formatter is, like numbers, the same a= s whatever guile does. (show #t (circular-list 1 2 3)) displays the same= as (display (circular-list 1 2 3)). Did I misunderstand your questions? --=20 Linus Bj=C3=B6rnstam On Wed, 12 Jun 2019, at 00:03, Mark H Weaver wrote: > Hi Linus, >=20 > Linus Bj=C3=B6rnstam writes: >=20 > > I just ported the reference implementation of SRFI-159/166 (166 bein= g > > the successor of 159) from the reference implementation in chibi > > scheme. The srfi document is here: > > https://srfi.schemers.org/srfi-166/srfi-166.html > > > > SRFI-166 is like (ice-9 format) on steroids, drenched in molasses. I= t > > can do a lot more than (ice-9 format), but about 3x slower. I haven'= t > > started trying to make it fast just yet, but there are some low > > hanging fruit (like speeding up simple cases). I will wait with > > optimization until the srfi is finalized (and also maybe hear with > > Alex what he has in mind before trying to half-ass it myself). > > > > Anyway, the repo is here: https://bitbucket.org/bjoli/guile-srfi-159= > > . I haven't ported the tests, but playing with it in guile and chibi= > > scheme produces the same result. Tests are up, but I'm travelling > > without computer the next week, so there is no time. >=20 > I would be in favor of integrating this into Guile at some point, > although first I would like to make a careful review of the > implementation to make sure that it integrates well with Guile's relat= ed > mechanisms, e.g. custom record printers, printer options, and print > states, and that it supports all Guile data types. In particular, I > remember finding it difficult to properly implement cycle detection > while supporting Guile's existing mechanisms. I'm not sure it can be > done without modifying Guile's built-in printer. >=20 > I'll also want to take a close look at the numeric formatter, to make > sure that it achieves the same properties as our built-in printer, > e.g. that it prints inexacts with the minimal number of digits require= d > to ensure that the same number will be read back in (unless specifical= ly > asked to limit the precision). >=20 > Anyway, thanks very much for sharing this! >=20 > Regards, > Mark >