From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Justin Veilleux Newsgroups: gmane.lisp.guile.devel Subject: integrating pretty printing into the language and repl machinery Date: Mon, 20 Sep 2021 11:01:31 -0400 Message-ID: <439e7ed1-1736-413b-73f1-14438b62891f@cock.li> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27089"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Icedove/78.12.0 To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon Sep 20 21:43:59 2021 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSPCk-0006hL-AI for guile-devel@m.gmane-mx.org; Mon, 20 Sep 2021 21:43:59 +0200 Original-Received: from localhost ([::1]:42942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSPCi-0001tk-Nm for guile-devel@m.gmane-mx.org; Mon, 20 Sep 2021 15:43:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSKne-0005Q2-7f for guile-devel@gnu.org; Mon, 20 Sep 2021 11:01:43 -0400 Original-Received: from mail.cock.li ([37.120.193.124]:53348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSKnb-0001X9-Is for guile-devel@gnu.org; Mon, 20 Sep 2021 11:01:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cock.li; s=mail; t=1632150094; bh=P6kSpLQtlDAk0rEJELLLiqiQ2GDm5ieBXxpZ9Qks/B8=; h=To:From:Subject:Date:From; b=UL4pC86mrUpG0BBNvad5X5tzGTbDGPEu97/+Pv4gdQ/V0eBuR0UyXbFa/cpQGeq5k yzMIrXtgXsQF4/uyqx6LtphzSxvmFCQKGxMYbeiMDtKJ5BbBZO1WoQ/zxF+1h0mKO+ ElK7E8t2S0aIwMY1Ulw9yHrCIN0svuJX70/bFePoJofqwKSK4gbdhAXuJEXXp1JrrC bCiU/iXU6+goKPtsNt/Nernhz0LfEh4zT4a63NUV63KfCVnnMDiwcsCJ7tLawt89BR SUaqtw/NNYUL8+dkEIe4+0ahkV9c1bDycadxr04rG8Ab5pUFlivTO6wMJ0lTCAIfR3 I9eSMf1fwj3xg== Content-Language: en-US Received-SPF: pass client-ip=37.120.193.124; envelope-from=terramorpha@cock.li; helo=mail.cock.li X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 20 Sep 2021 15:43:39 -0400 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20869 Archived-At: Hi guys. Recently, I wrote a lambda calculus parser and interpreter using guile's awesome compiler tower. It works relatively well, I'm able to enter expressions in the REPL and they are correctly executed. However, because of lambda calculus' nature, the interactive experience is far from fun. Since everything is a function, when I try and test my definition of addition of church encoded numbers, I'm met with an unfriendly `#'. I wrote a `render-function' procedure which, given an # from the lambda calculus world, will return a friendly representation such as `λa.λb.(b (b a))' I thought, "there must be a way to convince the REPL to use this function instead of the unhelpful `write'". While looking at the spec.scm file in language/ecmascript, I saw the ";; a pretty printer would be interesting" comment and was convinced that the #:printer field was my solution, but after investigating further, realized that it wasn't. In fact, if I understand correctly, there is currently no way of telling the REPL how I want the result of an expression printed. I have two questions. 1. What was the motivation for the #:printer slot in (system base language), if it isn't supposed to be used to print the result of evaluation (according to (repl common)) ? 2. If I were to do a bit of hacking, maybe add a #:pretty-printer slot and integrate it with the REPL, is that something that could get merged? Thank you.