<div dir="ltr">Hi,<div><br></div><div>The following program typechecks:</div><div><br></div><div><div>#lang typed/racket</div><div><br></div><div>(define-type R Real)</div><div>(define-type Rs (Listof R))</div><div>(define-type ROrRs (U R Rs))</div>

<div><br></div><div><div><div>(define (test [x : ROrRs]) : R</div><div>  (if (list? x)</div><div>      (if (null? x)</div><div>          (error "Less than one")</div><div>          (if (null? (cdr x))</div><div>

              (car x)</div><div>              (error "More than one")))</div><div>      x))</div></div></div></div><div><br></div><div>However, if we define R as an opaque type, e.g., using</div><div><br></div>
<div>
<div>(require/typed racket [#:opaque MyReal real?])</div><div>(define-type R MyReal)<br></div><div><br></div></div><div><div>then the program does not typecheck.</div><div><br></div><div>I was expecting that the program should typecheck independently of the actual type being used for R. What am I missing?</div>

</div><div><br></div><div>António Leitão.</div></div>