Sam, first I want to thank you for all your answers, you've helped me a lot. Thanks!<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
> I'm trying to implement a function wrapper, that given any function returns<br>
> a function of the same type, but that maybe applies a different argument. So<br>
> far I haven't been successful, and based on previous questions to the mail<br>
> list it seemed that I needed to go to an untyped module because I couldn't<br>
> constraint values to a given type.<br>
<br>
</div>In general, I don't think that any solution is going to work here.<br>
You can't take arbitrary functions and apply them to specific<br>
arguments (such as the string "blabla") in a type-safe way.<br></blockquote><div><br>For what I know, the design goal of Typed Racket is to avoid all runtime errors. Maybe that is too strict for programs like the one I intend to make. The idea of proposing a cast operation is to be able to establish a tradeoff between type safety and expressive power, according to the programmer needs.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
In you particular example, the function `f' is a constant function.<br>
But what if it expected `Integer' as its argument? Then your untyped<br>
code would be violating the type invariants.<br></blockquote><div><br>I think in that case a contract violation error should happen (?)<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
However, you can make your program work just by removing the<br>
parameterization over `A', and replacing that with `Any'. Then your<br>
program is safe, and your untyped module can safely call the function<br>
with any value it wants.</blockquote><div><br>In that case, my program can only work with values of type Any, and I'd need to make all functions Any -> (T Any) since I can't downcast to any other type, but since I'm passing functions as arguments I will have the problem of subtyping between functions... <br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
As an additional note, the `CAST' operation you describe below, can't<br>
do exactly what you expect, because it's runtime semantics depends on<br>
how you instantiate `B'. But that would mean that you'd have to<br>
generate code for the `CAST' without knowing what `B' is.</blockquote><div><br>do you think it can work if I do (CAST f (Integer -> Boolean)) instead?<br><br>Maybe the flaw in my reasoning is that I think that when you evaluate the polymorphic function, then you know what A and B are... so you should be able to cast a value to B, is not that so?<br>
<br>is it that you statically prove that the body is OK for all A and B and then you don't get that information when applying??<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Typed<br>
Racket, like ML or Haskell, doesn't pass type parameters around as<br>
values, so you can't do this.<br></blockquote><div><br>I don't know much about how the type system of ML or Haskell works.<br><br>What I'm trying to do, so you get the full picture, is to write a variation of Aspect Scheme in Typed Racket, so you can statically check that advice is well-typed. I couldn't type correctly the weaver function, so I tried with an untyped module. Maybe it is not possible at all??<br>
<br>Thanks again<br clear="all"></div></div><br>-- <br>Ismael<br><br>