Thank you for your answer , it does not really solve my general problem (I 
think), but it enabled progress. I changed my read-syntax to:
(define (read-syntax _ port)
  (define semi-ast (lex/j port))
  (define module-datum `(module mod/j typed/racket (,@(pre-expand 
semi-ast))))
  (datum->syntax #f module-datum))

So I am currently just attempting to compile to typed/racket syntax in a 
preparatory step, and then simply reuse the typed/racket expander. However, 
I am confused because my lexer (using parser-tools) and pre-expander are 
defined as standard functions. So in fact, they execute only once at run 
time, at the difference of a language implemented only with macros which 
would then have a clear compile time/run time distinction. I would have 
expected that writing a racket DSL would involve doing almost everything 
with macros, so is this way of doing things suboptimal?

Le lundi 15 avril 2019 19:49:56 UTC+2, Matthew Butterick a écrit :
>
>
>
> On Apr 12, 2019, at 6:00 PM, Raoul Schorer <raoul....@gmail.com 
> <javascript:>> wrote:
>
> Is there a way to achieve expansion to typed/racket from my custom 
> language, please?
>
>
> With the caveat that I'm probably overlooking some wrinkle pertaining to 
> Typed Racket — in general, the language of the expander module doesn't need 
> to be same as the language of the `#%module-begin`. I have used this 
> pattern before successfully. I don't know if this solves your problem in 
> the large. But it makes your toy example work.
>
>
> ;; expander.rkt
> #lang racket
> (require (prefix-in tr: (only-in typed/racket #%module-begin)))
> (provide (rename-out [module-begin/j #%module-begin]))
> (define-syntax (module-begin/j stx)
>   (syntax-case stx ()
>     [(_ a) #`(tr:#%module-begin 2)]))
>

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