[plt-scheme] 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: Fri May 28 15:44:43 EDT 2010

> You might want polymorphism here, or variable arity polymorphism, but
> I'd have to be sure of what you were trying to do.

I'm just looking for a way to represent functions - so I have this 'Fun' type storing the function's name, return type and arguments (up till now I have a number type and a string type only, represented by symbols N and S), and the action it's supposed to execute, which would be the scheme function if an appropriate one exists or a lambda expression otherwise.
Then I really just want to extract the code from this representation and apply it to some given object... just like in the made-up example I posted.

And this should work for every kind of function, so yes it should be variable arity, but also variable return types - just some general possibility to apply "anything at all" to anything - like if I had

(define-struct: Fun ((name : Symbol) (proc : Procedure) (args : (Listof Symbol)) (ret : Symbol))) 

(define f1 (make-Fun 'plus + '(N N) 'N)) 
((Fun-proc f1) 1 2) 

(define f2 (make-Fun 'substr substring '(S  N N) 'S)) 
((Fun-proc f2) "astring" 2 4) 

and it worked...
I don't know if this sounds silly, but I wouldn't know how I could represent functions in another way.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100528/c9e57338/attachment.html>

Posted on the users mailing list.