[racket] snips in redex traces

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue May 7 08:46:32 EDT 2013

Yes, sure:

#lang racket
(require redex 2htdp/image)
(define-language L
  (t ::= RED  YELLOW GREEN))

(define RED    (circle 14 "solid" "red"))
(define YELLOW (circle 14 "solid" "yellow"))
(define GREEN  (circle 14 "solid" "green"))

(define R
  (reduction-relation
   L
   (--> RED GREEN)
   (--> YELLOW RED)
   (--> GREEN YELLOW)))

(traces R (term RED)
        #:pp
        (λ (term port w txt)
          (write-special
           (case term
             [(RED) RED]
             [(GREEN) GREEN]
             [(YELLOW) YELLOW])
           port)))



On Tue, May 7, 2013 at 12:25 AM, David Van Horn <dvanhorn at ccs.neu.edu>wrote:

> Is it possible to render snips in redex traces?
>
> For example, here's something I'd like to write and have it result in a
> pretty traces window:
>
> #lang racket
> ;; Traffic lights as redex model
> (require redex 2htdp/image)
> (define-language L)
>
> (define RED    (circle 14 "solid" "red"))
> (define YELLOW (circle 14 "solid" "yellow"))
> (define GREEN  (circle 14 "solid" "green"))
>
> (define R
>   (reduction-relation
>    L
>    (--> (side-condition any_l (equal? (term any_l) RED))    ,GREEN)
>    (--> (side-condition any_l (equal? (term any_l) YELLOW)) ,RED)
>    (--> (side-condition any_l (equal? (term any_l) GREEN))  ,YELLOW)))
>
> (traces R (term ,RED))
>
> I'd also be happy if I could write a Term -> Snip function to supply as a
> pretty printer.
>
> David
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/**users <http://lists.racket-lang.org/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130507/b73e6f8e/attachment.html>

Posted on the users mailing list.