
- not auto-providing more closely adheres to idiomatic Racket - this commit changes: - define-typed-syntax - removed #:export-as option - define-base-type - removed #:no-provide option - define-type-constructor - removed #:no-provide option - type-out helps with providing defined types - in examples, move define and define-type-alias to ext-stlc - fix bug in reuse where renamed id not provided
31 lines
613 B
Racket
31 lines
613 B
Racket
#lang turnstile/lang
|
|
(extends "stlc+lit.rkt")
|
|
|
|
;; System F
|
|
;; Types:
|
|
;; - types from stlc+lit.rkt
|
|
;; - ∀
|
|
;; Terms:
|
|
;; - terms from stlc+lit.rkt
|
|
;; - Λ and inst
|
|
|
|
(provide (type-out ∀) Λ inst)
|
|
|
|
(define-type-constructor ∀ #:bvs >= 0)
|
|
|
|
(define-typed-syntax (Λ (tv:id ...) e) ≫
|
|
[([tv ≫ tv- : #%type] ...) () ⊢ e ≫ e- ⇒ τ]
|
|
--------
|
|
[⊢ e- ⇒ (∀ (tv- ...) τ)])
|
|
|
|
(define-typed-syntax inst
|
|
[(_ e τ:type ...) ≫
|
|
[⊢ e ≫ e- ⇒ (~∀ tvs τ_body)]
|
|
#:with τ_inst (substs #'(τ.norm ...) #'tvs #'τ_body)
|
|
--------
|
|
[⊢ e- ⇒ τ_inst]]
|
|
[(_ e) ≫
|
|
--------
|
|
[≻ e]])
|
|
|