noahstorym
2020-9-24 12:28:49

I met a strange problem in typed/racket:

#lang typed/racket/base (define-type Type1 (U Number (Parameter Type1))) (define-type Type2 (U Type1 Symbol)) (ann (ann 123 Type1) Type2) I think Type1 is the subtype of Type2 , so it must work. But it failed: Type Checker: type mismatch expected: Type2 given: Type1 in: 123


samth
2020-9-24 13:32:50

That’s very strange


samth
2020-9-24 13:34:04

It’s somehow a problem with the recursion in Type1



caente
2020-9-24 18:05:18

is there an extra runtime cost associated with using match? e.g. (define (sums xs) (match xs [(cons x tail) (cons (sums x) (sums tail))] [(list) xs] [x (add1 x)]))


samth
2020-9-24 18:12:43

no, that will generate good code