That's not possible in Typed Racket, no. Type checking is after macro expansion 
so type information doesn't even exist when your macro would expand.

However, hope is not lost. There is a new approach to typechecking with macros 
outlined in the Types as Macros paper by Stephen Chang and Alex Knauth, and 
reified in the `turnstile` Racket package. This approach interleaves 
typechecking and macro expansion, making types essentially macros with extra 
compile time metadata that alter the flow of macro expansion. In this case, 
types are actual *things* that exist at macro expansion time, so you could make 
a macro that interacted with types and used type information to decide how to 
expand.

On Tuesday, February 14, 2017 at 5:32:30 AM UTC-8, Robert Kuzelj wrote:
> given a type definition in typed/racket like
> 
>     (define-type BinaryTree (U Number (Pair BinaryTree BinaryTree)))
> 
> would it be possible to feed that type into a macro (aka not runtime) so that
> 
>     (define-transformed-type MyBinaryTree BinaryTree)
> 
> and would that macro be able to access the constituent elements and their 
> types of given type?

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