[racket] Re: [plt-scheme] Re: Typed scheme: Cannot apply expression of type Procedure, since it is not a function type
>>
>
> While I admit to being bored of the category theory, I'm always happy
> to have questions about Typed Scheme.
>
Glad to hear this :-;
> What you really want to write is this:
>
> (define-struct: (ret args ...) Fun ((name : Symbol) (proc : (args ...
> -> ret)) (args : (Listof Symbol)) (ret : Symbol)))
yes, I think this would be it... But for this I've found a workaround now, thanks to Noel (although this workaround leads to some horrible code duplication I don't know how to avoid, in the line of
(match o
..........
((struct AppFun (f o1 o2)) (let ((o1 (eval-operand t o1)) (o2 (eval-operand t o2)))
(match o1
((struct S (s1)) (match o2
((struct S (s2)) (case f
((strapp) (make-S ((StrApp-p strapp) s1 s2)))))
((struct N (n)) (case f
((substr) (make-S ((Substr-p substr) s1 n))))))))
- I'm talking of the (Substr-p substr) and (StrApp-p strapp) , I would have this same code for extracting the function in every case...
But the real reason why I'm thinking of "giving up" and switching to untyped scheme is another one - I'm totally stuck with type conversion problems as the "implemented language" has types itself.
For starters, I have 2 types only, strings and numbers, which I define like this:
(define-datatype Value
(S ((s : String)))
(N ((n : Real))))
Now the problem is, I want to apply scheme functions on them. The problem arises e.g. with scheme's substring, which expects an Exact-Nonnegative-Integer as the second argument. Now I can't manage to convert the Real I have to to an Exact-Nonnegative-Integer... or I don't see how. In untyped scheme, I think this should work:
(inexact->exact (truncate n))
but in typed it gives me an Exact-Rational and I can't get on further. Is there a solution for this? Also I think I will incur more difficulties of this kind if I go on... when integrating other functions.
This in general is what I meant by "it might get too complicated to use typed scheme when having to implement types yourself" (even in a very simplified manner).
Ciao
Sigrid
_________________________________________________
For list-related administrative tasks:
http://list.cs.brown.edu/mailman/listinfo/plt-scheme
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users