[racket] typed racked questions

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Apr 30 08:48:38 EDT 2012

On Mon, Apr 30, 2012 at 12:51 AM, Bikal Gurung <gbikal at gmail.com> wrote:
> Hi All,
> I am investigating typed racket. I was wondering if someone could help with
> answering the questions below.
> 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?

Yes, you can mix typed modules and untyped modules in the same
program.  This is one of the most fundamental features of Typed
Racket.  To use a typed module from an untyped module, just require it
-- contracts are inserted automatically to check the operation.  To
use an untyped module from a typed module, use `require/typed' to
specify the type.

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

This is very much an issue of style.  I think there are a number of
advantages of type systems for maintenance, optimization,
documentation, and organization, so I encourage you to use Typed
Racket.  However, if you use plain Racket, Typed Racket is designed to
make it easy to switch, a module at a time, when you decide you want

> 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.

Yes, Typed Racket has an optimizing compiler (by Vincent St-Amour)
which uses the type information to make your program go faster.  You
can see some benchmark results in our papers
http://www.ccs.neu.edu/racket/pubs/padl12-stff.pdf and
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 just `require` the typed module, and it should work.

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

The Typed Racket type system contains a number of features that go
beyond what's supported in Hindley/Milner style type systems, and so
we can't use that inference system.  Currently, Typed Racket uses
local type inference to infer many of the types in your program, but
we'd like to infer more of them -- this is an ongoing area of
research.  However, inferring all the types in the program, the way
that ML and Haskell do, is not a goal of Typed Racket -- having type
annotations there makes the program self-documenting and easier to
understand, improves type error messages, and supports advanced type
system features.

Thanks for your interest in Typed Racket, and if you have any more
questions, please ask.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.