From: Justin Veilleux <terramorpha@cock.li>
To: guile-devel@gnu.org
Subject: integrating pretty printing into the language and repl machinery
Date: Mon, 20 Sep 2021 12:54:50 -0400 [thread overview]
Message-ID: <cd4270f8-009f-7fda-a29a-5344937c25c8@cock.li> (raw)
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 `#<procedure>'.
I wrote a `render-function' procedure which, given an #<procedure> 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.
next reply other threads:[~2021-09-20 16:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 16:54 Justin Veilleux [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-09-20 15:01 integrating pretty printing into the language and repl machinery Justin Veilleux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cd4270f8-009f-7fda-a29a-5344937c25c8@cock.li \
--to=terramorpha@cock.li \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).