Statically typed scheme

Very interesting post on LtU by Kevin Millikin. He shows a simple transformation to make scheme statically typed. You represent values as a (type, thunk) pair. You make all your primitive operations check the type of their operands before generating a (type, thunk) result. And you simply force the thunk at the top level.

Example output:

Welcome to MzScheme version 208, Copyright (c) 2004 PLT Scheme, Inc.

> (t-app (t-lambda (x : int) (plus x x)) (return int 42))
(int . #)

> (run (t-app (t-lambda (x : int) (plus x x)) (return int 42)))
84

> (t-lambda (x : string) (plus x x))
plus: type error

> (t-app (t-lambda (x : string) x) (return int 42))
t-app: type error

Posted on June 4, 2006 07:27 PM
More languages articles

Comments
Post a comment









Remember info?




Prove you're human. Type "human":