Now my example typechecks, but effectively I can't do anything with the function :-( so it is very unpractical<br><br>(: f ((Nothing -> Any) -> True))<br>(define (f g) #t)<br>(f (lambda: ([x : Integer]) #t))<br><br>
is there any way to make the typechecker happy, but being able to apply functions?<br><br>For me, it would be something like:<br><br>(: f ((Bottom -> True) -> True))<br>(define (f g) (g 1))<br>(f (lambda: ([x : Integer]) #t)) <br>
<br>?? or any other workaround?<br>should I instead use an untyped module?<br><br>Thanks<br><br><br><div class="gmail_quote">2011/11/28 Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5">On Mon, Nov 28, 2011 at 10:35 AM, Ismael Figueroa Palet<br>
<<a href="mailto:ifigueroap@gmail.com">ifigueroap@gmail.com</a>> wrote:<br>
> As Any is supertype of all values, what is the equivalent type for function<br>
> types?<br>
><br>
> (Any -> Any) does not work because of the contra-variant requirement of the<br>
> argument.<br>
><br>
> (: f ((Any -> Any) -> True))<br>
> (define (f g) #t)<br>
><br>
> (f (lambda (x) x) #t) ;; works<br>
> (f (lambda: ([x : Integer]) #f)) ;; does not work<br>
><br>
> The error is:<br>
><br>
> Type Checker: Expected (Any -> Any), but got (Integer -> Any) in: (lambda:<br>
> ((x : Integer)) #f)<br>
><br>
> If I understand it correctly, the type I'm looking for is (Bottom -> Any),<br>
> which satisfies the contra-variant and variant requirements for function<br>
> subtyping. However, the Bottom type doesn't seem to exist (at least at the<br>
> user-level, because I remember seeing some error messages that mentioned Top<br>
> and Bottom).<br>
<br>
</div></div>You're probably looking for the type `Nothing'. Note that functions<br>
of type `(Nothing -> T)' are very hard to apply, though.<br>
<font color="#888888"><br>
--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Ismael<br><br>