[racket] [plt-scheme] Re: Typed scheme: Cannot apply expression of type Procedure, since it is not a function type

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Jun 9 04:13:45 EDT 2010

On Tue, Jun 8, 2010 at 9:07 PM, keydana at gmx.de <keydana at gmx.de> wrote:

> I've downloaded racket now, and really it works without the casts (at least my example), but to understand I tried your solutions on my case: David's cast worked fine, but your conversion function Noel did not work in my case (in plt 4.2.5), there was a problem with the Option type:

Ah yes, I use the assert function as well. So number->exact-integer is
Number -> Option Integer and assert is Option 'a -> 'a. The type defns
tell you this.

You should definitely read other's code. I recommend my code, because
it's awesome. Better yet, you should implement the missing parts for
me ;-P (Really, do read code. It is very useful. I happen to think my
code is fairly simple, but you might not find this is the case if you
don't understand the application domain.)

> O course it's not a problem now any more, the reason I tried this out was that looking at (both your) code, I was puzzled how these casts would work in TS... my main experience with casts being from Java, I was missing something like the (Object) part in, e.g.,
> return (Object) astring;
> But it looks like in TS, it's the return type of the function which accomplishes everything, - would that be correct?

I don't understand what you mean by "it's the return type of the
function which accomplishes everything". Anyway, TS has what is called
"occurrence typing". Basically this means you can use predicates as
...err... type casts. This is going beyond my knowledge so I'll just
refer you to the paper and LtU discussion:



Posted on the users mailing list.