[racket] typed racked questions

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Mon Apr 30 08:34:55 EDT 2012

At Mon, 30 Apr 2012 05:51:00 +0100,
Bikal Gurung wrote:
> 1) Can we mix/import modules written in untyped racket to a module that is
> used typed racket. I have experimented with a few modules using and they
> seem to work in general but not really sure about the mechanism that makes
> it work. How does racket make the untyped code and typed code work together
> if they do? Is this in a case by case basis, ie. module/library by library
> basis?

Contracts are applied at the boundaires between types and untyped
code. These contracts check that whathever comes from an untyped module
respects the typed module's invariants. Contracts are generated from
types, so this works for any module.

> 2) What is the canonical racket paradigm? use typed racket or untyped
> racket? Or is this more an issue of a preference/style?

It's a matter of preference, I would say.

Typed Racket was designed to make it easy to port untyped Racket code to
it. It's possible to write your programs in untyped Racket, then as the
code base grows larger, add types one module at a time.

> 3) Are typed racket programs faster than untyped ones? The documentation
> says so but I was wondering if there has been any benchmark or study being
> done on this topic.

Typed Racket does perform optimization. Whether or not they apply
depends on the program. If you want to know if your program benefits
from Typed Racket's optimizations, click the Performance Report button
in DrRacket and green highlights will appear where optimizations were
performed. You can click these highlights for more information.

As for benchmarks, check out:
http://www.ccs.neu.edu/racket/pubs/pldi11-thacff.pdf

> 4) Can typed racket module be used in the context of untyped racket module?

Yes, you can require a Typed Racket module from a Racket module.

> 5) Is there a Hindlye/Milner style type inferencing algorithm for typed
> racket being worked on?

Currently, Typed Racket performs local type inference. It can infer most
types inside function bodies, but it requires type annotations for
functions. Global type inference would be nice, but we don't know how to
do it. Several features of the type system make inference hard.

Vincent

Posted on the users mailing list.