User loginNavigation |
How to type polymorphic variants with open generic functions?I'd like to implement a language with polymorphic variants, but instead of using pattern matching, I'd like to use Common Lisp-like generic functions that are defined with Where in pseudo-ML I'd say
let length list =
case list of
`Nil -> 0
| `Cons _ cdr -> 1 + length cdr
in my language I'd say (define-generic length) (define-method (length `Nil) 0) (define-method (length (`Cons _ cdr)) (+ 1 (length cdr))) I'd like to able to add methods in different compilation units, and only type-check generic functions at the end of compile-time, once all methods are known. Another possibility might be to defer type checking of generic functions to link time. Any ideas or pointers to things I should check out? I'm currently reading Simple Type Inference for Structural Polymorphism, and TAPL is lying on the coffee table. By Manuel J. Simoni at 2012-10-08 17:50 | LtU Forum | previous forum topic | next forum topic | other blogs | 3995 reads
|
Browse archives
Active forum topics |
Recent comments
3 days 4 hours ago
3 days 5 hours ago
3 days 5 hours ago
3 weeks 3 days ago
4 weeks 2 days ago
4 weeks 2 days ago
4 weeks 3 days ago
4 weeks 3 days ago
4 weeks 4 days ago
4 weeks 6 days ago