stlc + ext:
- define-primop requires parens around type - define-syntax/type-rule renamed to define-typed-syntax - use 2 arg + primop instead of vararg
This commit is contained in:
parent
d93b88d8b5
commit
635f9370c0
|
@ -1,8 +1,13 @@
|
|||
#lang s-exp "stlc-via-racket-extended.rkt"
|
||||
((λ ([f : (Int → Int)] [x : Int]) (f x))
|
||||
(λ ([x : Int]) (+ x x 1))
|
||||
((λ ([f : (Int → Int)] [x : Int])
|
||||
(f x))
|
||||
(λ ([x : Int]) (+ x x))
|
||||
10)
|
||||
((λ ([x : Int]) (+ x 1 3)) 100)
|
||||
((λ ([x : Int]) (+ x 1)) 100)
|
||||
((λ ([f : (Int Int → Int)] [x : Int] [y : Int]) (f x y))
|
||||
+
|
||||
100
|
||||
200)
|
||||
|
||||
;; extra tests
|
||||
; test #%datum extension
|
||||
|
|
|
@ -13,17 +13,18 @@
|
|||
|
||||
(define-literal-type-rule integer : Int)
|
||||
|
||||
(define-simple-syntax/type-rule
|
||||
(define-primop + : (Int Int → Int))
|
||||
#;(define-simple-syntax/type-rule
|
||||
(+ e ...) : Int
|
||||
#:where
|
||||
(e : Int) ...)
|
||||
|
||||
(define-simple-syntax/type-rule
|
||||
(define-typed-syntax
|
||||
(λ ([x : τ] ...) e) : (τ ... → τ_body)
|
||||
#:where
|
||||
(let τ_body := (typeof e)))
|
||||
|
||||
(define-simple-syntax/type-rule
|
||||
(define-typed-syntax
|
||||
(#%app f e ...) : τ2
|
||||
#:where
|
||||
(let (τ1 ... → τ2) := (typeof f))
|
||||
|
|
Loading…
Reference in New Issue
Block a user