sweet-racket icon indicating copy to clipboard operation
sweet-racket copied to clipboard

Support for infix dots

Open wilbowma opened this issue 9 years ago • 2 comments
trafficstars

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)

wilbowma avatar Jun 20 '16 23:06 wilbowma

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}

AlexKnauth avatar Jun 20 '16 23:06 AlexKnauth

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

wilbowma avatar Jun 21 '16 00:06 wilbowma