I think you will probably want to define an applicable struct type with
custom printing behavior and then replace Racket's lambda with your own
macro to create instances of that struct type. I think what you want may be
more complex than this, but here's an example that simply carries along its
own source text:

#lang racket

(require (for-syntax syntax/parse))

(struct my-lambda-record (name proc)
  #:property prop:custom-print-quotable 'never
  #:methods gen:custom-write
  [(define (write-proc this out mode)
     (print (my-lambda-record-name this) out 1))]
  #:property prop:procedure (struct-field-index proc))

(define-syntax (my-lambda stx)
  (syntax-parse stx
    [(_ (formal:id) body:expr)
     #`(my-lambda-record '#,stx (lambda (formal) body))]))


Then for example:


> (my-lambda (x) (my-lambda (y) x))
(my-lambda (x) (my-lambda (y) x))



-Philip

On Tue, May 23, 2017 at 4:10 PM, Vityou <zlee...@gmail.com> wrote:

> In lambda calculus, the function is the only datatype, so it would be
> useful to see the body of a function when it is returned in some expression
> in the repl (so you can see what number was returned or some other
> encoding).  I have got this working by making a language where the reader
> turns the file into a list and #%module-begin just prints the result of
> applying an eval function that works with lists to the list from the
> reader.  This works quite well:
>
> > x
> x
> > ((lambda (x) (lambda (y) x)) f)
> (function (lambda (y) x) ((x f)))
>
>
> but I was thinking of including some things like a non-recursive define
> and provide and require, but the current list based system I have right now
> won't work.  Is there any way that I could have racket print its own
> lambdas like mine above?  Or is there any way to achieve the same effect
> (the effect being able to print lambdas like above and use define require
> and provide).  I attached the expander of the list based lambda calculus if
> you want to look at it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to