<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Is there a way of specifying filters in typed racket so that if it returns true, it knows it’s a certain type, but if it returns false, it doesn’t mean that it’s not that type (or the other way around).  <div><br></div><div>For example:</div><div><font face="Courier New">(: string-with-length-1? (Any -> Boolean : #:if-true String #:if-false (U String Any)))</font></div><div><font face="Courier New">(define (string-with-length-1? x)</font></div><div><font face="Courier New">  (if (string? x)</font></div><div><font face="Courier New">      (one? (string-length x))</font></div><div><font face="Courier New">      #f))</font></div><div><br></div><div>I know there’s something like this somewhere.</div><div><br></div><div>When I tried it, it gave me an error message (I expected that), but that error message said something about #:+ and #:-</div><div><br></div><div>After trying some stuff and guessing stuff from error messages, and just to try it and see what happened, I tried this:  </div><div><div><font face="Courier New">(: string-with-length-1? (Any -> Boolean : #:+ (String @ x) #:- ((U String Any) @ x)))</font></div><div><font face="Courier New">(define (string-with-length-1? x)</font></div><div><font face="Courier New">  (if (string? x)</font></div><div><font face="Courier New">      (one? (string-length x))</font></div><div><font face="Courier New">      #f))</font></div></div><div>And it gave me this weird error message:</div><div><div><font face="Courier New">. Type Checker: type mismatch;</font></div><div><font face="Courier New"> mismatch in filter</font></div><div><font face="Courier New">  expected: ((String @ x) | Top)</font></div><div><font face="Courier New">  given: ((String @ x) | Top) in: (if (string? x) (one? (string-length x)) #f)</font></div></div><div><br></div><div>What?  If it’s expecting <span style="font-family: 'Courier New';">((String @ x) | Top)</span>, and I’m giving it <span style="font-family: 'Courier New';">((String @ x) | Top)</span>,  then what’s the problem?</div><div><br></div><div>And is there any documentation anywhere about this?</div><div><br></div><div><br></div></body></html>