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

From: keydana at gmx.de (keydana at gmx.de)
Date: Tue Jun 8 16:07:57 EDT 2010

Noel & David,

thanks a lot for sharing your code!

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:

(substring "qqq" (number->exact-integer (truncate (inexact->exact 1.2))))
Type Checker: No function domains matched in function application:
Domains: String Integer
         String Integer Integer
Arguments: String (U Integer False)
 in: (substring "qqq" (number->exact-integer (truncate (inexact->exact 1.2))))

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?

Thanks again

Am 08.06.2010 um 07:35 schrieb Noel Welsh:

> On Mon, Jun 7, 2010 at 1:08 PM, keydana at gmx.de <keydana at gmx.de> wrote:
>> Finally I've found the time to try this - but it gives me a Real (same with round):
>> (truncate (inexact->exact 1.222))
>> - : Real
>> 1
>> So I still have the typing error, the substring function insisting on an Integer...
> This file contains type conversion functions that I've used in my code:
> http://github.com/noelwelsh/bayesian-scan-matching/blob/master/util.ss
> HTH,
> N.

Posted on the users mailing list.