unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* integrating pretty printing into the language and repl machinery
@ 2021-09-20 16:54 Justin Veilleux
  0 siblings, 0 replies; 2+ messages in thread
From: Justin Veilleux @ 2021-09-20 16:54 UTC (permalink / raw)
  To: guile-devel

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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* integrating pretty printing into the language and repl machinery
@ 2021-09-20 15:01 Justin Veilleux
  0 siblings, 0 replies; 2+ messages in thread
From: Justin Veilleux @ 2021-09-20 15:01 UTC (permalink / raw)
  To: guile-devel

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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-20 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 16:54 integrating pretty printing into the language and repl machinery Justin Veilleux
  -- strict thread matches above, loose matches on Subject: below --
2021-09-20 15:01 Justin Veilleux

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).