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

From: Noel Welsh (noelwelsh at gmail.com)
Date: Sat May 29 01:35:39 EDT 2010

I don't know that Typed err... Racket can express what you want. Sam
can give a definitive answer.

One way to solve this problem is to enumerate all the functions you'll
ever use, which a type defn like:

type Fun = Plus Number Number -> Number | Minus Number Number ->
Number | String-Append String String -> String | ...

I've MLish syntax here as it is a bit more compact. This is basically
how you get dynamic checks into a statically typed language.


On Fri, May 28, 2010 at 8:44 PM, keydana at gmx.de <keydana at gmx.de> wrote:
> 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.
> Ciao,
> Sigrid
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.