takikawa / sweet-racket

A port of sweet expressions to Racket
http://pkg-build.racket-lang.org/doc/sweet/index.html
Other
47 stars 10 forks source link

Support for infix dots #35

Open wilbowma opened 8 years ago

wilbowma commented 8 years ago

I want to write an infix expression but I can't use {} to make it infix, but neither can I use infix dots:

define-syntax ⊢
 syntax-rules (:)
   [(⊢ Γ e : t) (void)]

;; I didn't expect this would work
{Γ ⊢ e2 : t}

;; but this doesn't work either
(Γ . ⊢ . e2 : t)
AlexKnauth commented 8 years ago

Infix dots would be a good thing to support. I've also wanted to use them for -> contracts.

But for your case, if you define an nfx macro, you can have it recognize and transform it:

#lang sweet-exp racket

define-syntax ⊢
  syntax-rules (:)
    [(⊢ Γ e : t) (void)]

define-syntax nfx
  syntax-rules (⊢ :)
    [(nfx Γ ⊢ e : t)
     (⊢ Γ e : t)]

{Γ ⊢ e2 : t}
wilbowma commented 8 years ago

Oh. Hm. That seems awkward and non-local, but I suppose that works.