Random notes on Implementing Parametric Polymorphism
This is more difficult because we have to maintain knowledge of the
bindings of type-variables in our environment, as well as the
type-bindings of ordinary variables. So I haven't got detailed
notes on how to do it.
... Defining the method for quoted constants
We will treat quoted constants as cartesian products, rather than
lists. So we want to ascribe to '(4 5 (7 8)) the type
(>< integer? integer? (>< integer? integer?))
(define (method_quote args env)
(type_list_structure (car args))
)
)
(define (type_list_structure obj)
(if (pair? obj) (cons '>< (map type_list_structure obj))
(type_constant obj) ) )
(add_method! 'quote method_quote)
(example
'(type_check ''(23 "pussycats" ("eating" "fish")) '() )
'(>< integer? string? (>< string? string?))
)
--!>