georges-duperon
2017-5-13 19:27:53

@pnwamk Thanks for the tip about using Regexp instead of -Regexp! I’m checking that everything runs fine now, but I have issues with tc-err. The test [tc-err (ann (ann #px#"abc" Byte-PRegexp) PRegexp)] fails: actual: (tc-results (list (tc-result PRegexp (Top \| Bot) -)) #f) expected: (tc-results (list (tc-result Nothing (Bot \| Bot) -)) #f) I feel like I should supply one of the ret:err-return or ex:expected arguments to tc-err, but their exact meaning is not documented. Any hint?


pnwamk
2017-5-13 19:29:31

I don’t know there exact meaning either and wish it was documented =( that code is really clever/cute and I always struggle re-parsing what exactly it does


georges-duperon
2017-5-13 19:35:26

@pnwamk Seems like this does the trick (as I understand it, tc-err checks that the return type is correct, even if an error is there, and ann is clever enough to indicate its return type, even when it fails) [tc-err (ann (ann #px#"abc" Byte-PRegexp) PRegexp) #:ret (tc-ret -PRegexp)]


georges-duperon
2017-5-13 19:53:29

@pnwamk Sorry for bothering you once more: in generalize.rkt, should I do [(? (lambda (t) (subtype t -Base-Regexp))) -Base-Regexp] (to generalize literals which are regexp? to -BaseRegexp), or should I generalize to -Regexp, i.e. [(? (lambda (t) (subtype t -Base-Regexp))) -Regexp] ? I tried to see if it made any difference in the way the type is printed when entering a literal #rx"abc" at the REPL, but it makes no difference. I also expected (let ([x #rx"foo"]) (set! x #px"foo")) to fail in the second case (generalizing to -Base-Regexp), but it still works (so it seems something else is further generalizing -Base-Regexp to -Regexp). Any preference? I feel this will matter only if/when we decide to make the Base-Regexp type “public” (for now it seems to be used internally only).


pnwamk
2017-5-13 22:20:46

@georges-duperon sorry for the delay — I’m not super familiar with typing regexps… my gut is to favor the more general Regexp, but like I said I don’t have much experience working with those in practice


georges-duperon
2017-5-13 22:22:59

@pnwamk Okay, thanks! I’ll put Regexp then (I think if we expose Basic-Regexp at some point, the user could always force it with (ann #rx"abc" Basic-Regexp).