[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: Mon May 31 15:43:57 EDT 2010

On Sat, May 29, 2010 at 7:48 AM, keydana at gmx.de <keydana at gmx.de> wrote:
> You're getting up even earlier than me on a Saturday :-;

It's not through choice...

Your other email shows you got my rather tersely presented idea. Just
a note about this idea, as it has some wider significance. You'll
sometimes see people say that you can trivially express "dynamic
typing" in a statically typed language. You just define a type like

type Any = Plus Number Number -> Number | String-Append String String
-> String | ...

That is, you define a type that encompasses all possible values in
your language. Then every use has checks like:

match A-Value
  Plus fn => fn val1 val2
 | error "Expected function plus found something else\n"

Notice that our code will type check perfectly but every expression
has type Any and these types are essentially useless. This gives you
an idea of what static typing does and doesn't check. Basically types
are statically checked, but cases (in the discriminated union sense)
aren't. Cases are how you inject dynamic checks into statically typed
languages. Where you draw the line between types and cases determines
what you do and don't statically check.

Hope that makes sense; I'm assuming you know some ML. I probably got
some terminology wrong.


Posted on the users mailing list.