rosette2: support applying symbolic function types

This commit is contained in:
AlexKnauth 2016-08-25 10:07:00 -04:00
parent 9743656778
commit cc27c76ab8
2 changed files with 16 additions and 1 deletions

View File

@ -142,7 +142,16 @@
(string-join (stx-map type->str τs_given) ", ")
(string-join (map ~s (stx-map syntax->datum expressions)) ", ")))])
--------
[ [_ (ro:#%app e_fn- e_arg- ...) : τ_out]]])
[ [_ (ro:#%app e_fn- e_arg- ...) : τ_out]]]
[(_ e_fn e_arg ...)
[ [e_fn e_fn- : (~U* τ_f ...)]]
[ [e_arg e_arg- : τ_arg] ...]
#:with (f a ...) (generate-temporaries #'(e_fn e_arg ...))
[([f _ : τ_f] [a _ : τ_arg] ...)
[(app f a ...) _ : τ_out]]
...
--------
[ [_ (ro:#%app e_fn- e_arg- ...) : (U τ_out ...)]]])
;; ---------------------------------
;; Types for built-in operations

View File

@ -196,3 +196,9 @@
"given \\(Ccase-> .*\\(C→ NegInt \\(U NegInt Zero\\)\\) .*\\(C→ Zero PosInt\\) "
".*\\(C→ PosInt PosInt\\) .*\\(C→ Nat PosInt\\) .*\\(C→ Int Int\\)\\)"))
;; applying symbolic function types
(check-type ((λ ([f : (U (C→ CInt CInt))]) (f 10)) add1) : Int -> 11)
;; it's either (→ CInt CInt) or (→ CInt CBool), but not both, so
;; add1 can have this type even though it never returns a boolean
(check-type ((λ ([f : (U (C→ CInt CInt) (C→ CInt CBool))]) (f 10)) add1) : (U Int Bool) -> 11)