[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: Thu Jun 10 15:54:16 EDT 2010

>> 
> 
> 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.

Oh yes, mea culpa mea culpa mea culpa :-; In fact I wanted to reply you quickly and had little time to try everything out... seems like it went TOO quickly really :-;

> 
> 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.)


OK where's the schedule :-; No but really, of course this would be very useful and I want to do it more. The thing is, you probably don't imagine how much time it can take others (me!) to understand, e.g., the arith.rkt snippet from
http://docs.racket-lang.org/guide/hash-reader.html#(part._.Source_.Locations).

In general, I would say I've found the leap from say, books on / using scheme (including HTDP) to some PLT code I encountered (in blogs / tutorials, for example) too hard in the beginning. But this was less because of missing domain knowledge but because of constructs the code authors used that I didn't know and that I had too much difficulty understanding in the PLT Reference: Trying to remember, among those were parameters, custodians, comprehensions (which would have been easier had I known some Haskell at that time, of course...). Or when I think of the leap from the webserver tutorial (which was easy to follow) to the webserver docs... And then, there's still the fear of all the macros in others' code :-;

Today still, I often have difficulties understanding things in the Reference. But you're right, all this - spanning the gap between own code and all he possibilities of the language - might really become easier by reading others' code :-)







> 
>> 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:
> 
> http://lambda-the-ultimate.org/node/2622
> 
> N.



Posted on the users mailing list.